当前位置: 首页>>代码示例>>C#>>正文


C# TabPage.Dispose方法代码示例

本文整理汇总了C#中System.Windows.Forms.TabPage.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TabPage.Dispose方法的具体用法?C# TabPage.Dispose怎么用?C# TabPage.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TabPage的用法示例。


在下文中一共展示了TabPage.Dispose方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: buttonCloseTab_Click

 private void buttonCloseTab_Click(object sender, EventArgs e)
 {
     TabPage tabActive = new TabPage();
     tabActive = tabControlMainTabNav.SelectedTab;
     if(tabActive.Text!="Resumen")
     {
         tabControlMainTabNav.TabPages.Remove(tabActive);
         tabActive.Dispose();
     }
 }
开发者ID:ramiroreal,项目名称:GestorFacturas,代码行数:10,代码来源:Form1.cs

示例2: CloseFile

 public void CloseFile(TabPage tp)
 {
     string FileName = (tp.Tag as Data).FullPathName.ToLower();
     string exeName = (tp.Tag as Data).EXEFileName;
     if (RunnerManager.IsRun(exeName))
         RunnerManager.Stop(exeName);
     if ((tp.Tag as Data).DocumentChanged)
         if (!QuestionAndSaveFile(tp))
         {
             SaveCanceled = true;
             return;
         }
     if (tabControl1.TabPages.Count != 1)
     {
         if((tp.Tag as Data).DocumentSavedToDisk)
             AddLastFile(CurrentSourceFileName);
         if (LastSelectedTab != null && !LastSelectedTab.IsDisposed)
             tabControl1.SelectedTab = LastSelectedTab;
         if (tp == ActiveTabPage) 
             ActiveTabPage = null;
         OutputTextBoxs.Remove(tp);
         tp.Dispose();
     }
     CheckErrorListAndClear(FileName);
     if (tabControl1.TabPages.Count == 1)
     {
         CloseButtonsEnabled = false;
     }
     SaveAllButtonsEnabled = !AllSaved();
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:30,代码来源:Form1.cs

示例3: CloseTabPage

        private void CloseTabPage(TabPage page)
        {
            this.InvokeEx(() =>
            {
                int indexOf = this.TabControl.TabPages.IndexOf(page);

                if (indexOf != -1)
                {
                    PanelHelpers.DeinitializeEntitySelectors(page);
                    int nextTab = (indexOf != this.TabControl.TabPages.Count - 1) ? indexOf + 1 : indexOf - 1;

                    if (this.TabControl.TabPages.Count > 1 && indexOf == this.TabControl.SelectedIndex)
                        this.TabControl.SelectedIndex = nextTab;

                    this.TabControl.TabPages.Remove(page);
                    // its very important to dispose the page, otherwise its HWND won't be released in
                    // a timely manner, possibly leading to a crash
                    page.Dispose();
                }
            });
        }
开发者ID:CyberBotX,项目名称:sda-donation-tracker,代码行数:21,代码来源:MainForm.cs

示例4: DisposeTabPage

		private void DisposeTabPage(TabPage tabPage)
		{
			tabPage.DisposeChildControls();
			tabPage.Dispose();
		}
开发者ID:saycale,项目名称:MSSQLServerAuditor,代码行数:5,代码来源:TabPageBuffer.cs

示例5: CreateTab

        internal static TabPage CreateTab(IViewContent content, string imgKey)
        {
            TabPage page = new TabPage();
            page.ImageKey = imgKey;
            page.Text = content.Title;
            page.ToolTipText = content.Description;
            page.Tag = content;

            content.TitleChanged += (sender, e) =>
            {
                page.Text = content.Title;
            };
            content.DescriptionChanged += (sender, e) =>
            {
                page.ToolTipText = content.Description;
            };
            content.ViewContentActivating += (sender, e) =>
            {
                //Find matching hidden tab entry, and restore
                HiddenTab hiddenTab = null;
                foreach (var htab in _hiddenTabs)
                {
                    if (htab.Tab == page)
                    {
                        hiddenTab = htab;
                    }
                }
                if (hiddenTab != null)
                {
                    hiddenTab.Parent.TabPages.Add(page);
                    var indx = hiddenTab.Parent.TabPages.IndexOf(page);
                    hiddenTab.Parent.SelectedIndex = indx;
                    _hiddenTabs.Remove(hiddenTab);
                }
                else //Wasn't hidden in the first place
                {
                    var tabs = page.Parent as TabControl;
                    if (tabs != null)
                    {
                        var indx = tabs.TabPages.IndexOf(page);
                        tabs.SelectedIndex = indx;
                    }
                }
            };

            content.ViewContentClosed += (sender, e) =>
            {
                //Remove itself from the tab control
                var tabs = page.Parent as TabControl;
                if (tabs != null && tabs.TabPages.Contains(page))
                {
                    if (!Platform.IsRunningOnMono)
                    {
                        var idx = tabs.TabPages.IndexOf(page);
                        tabs.TabPages.Remove(page);
                        if (idx > 0)
                            tabs.SelectedIndex = --idx;
                    }
                    else
                    {
                        int idx = -1;
                        //HACK: Mono (2.4) will chuck a hissy fit if we remove
                        //a tab from a TabControl that has a selected tab so we
                        //have to null the selected tab, but this cause weird
                        //visual effects once the tab is removed, so we record
                        //the selected index, so we can assign the one beside it
                        //to be the selected tab after removal.
                        if (tabs.SelectedTab == page)
                        {
                            idx = tabs.SelectedIndex;
                            tabs.SelectedTab = null;
                        }
                        tabs.TabPages.Remove(page);

                        if (idx > 0)
                        {
                            idx--;
                            tabs.SelectedIndex = idx;
                        }
                        else
                        {
                            //Set to first tab if available.
                            if (tabs.TabCount > 0)
                            {
                                tabs.SelectedIndex = 0;
                            }
                        }
                    }
                    page.Dispose();
                }
            };

            content.ViewContentHiding += (sender, e) =>
            {
                //Store in hidden tabs collection
                var tabs = page.Parent as TabControl;
                if (tabs != null && tabs.TabPages.Contains(page))
                {
                    var htab = new HiddenTab() { Parent = tabs, Tab = page };
                    _hiddenTabs.Add(htab);
//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:TabFactory.cs

示例6: AddToolbarAndBrowserToTab

        protected void AddToolbarAndBrowserToTab(TabPage tabPage, GeckoWebBrowser browser)
        {
            TextBox urlbox = new TextBox();
            urlbox.Top = 0;
            urlbox.Width = 200;

            Button nav = new Button();
            nav.Text = "Go";
            nav.Left = urlbox.Width;

            Button newTab = new Button();
            newTab.Text = "NewTab";
            newTab.Left = nav.Left + nav.Width;

            Button stop = new Button
                          {
                          	Text = "Stop",
                          	Left = newTab.Left + newTab.Width
                          };

            Button closeTab = new Button();
            closeTab.Text = "GC.Collect";
            closeTab.Left = stop.Left + stop.Width;

            Button closeWithDisposeTab = new Button();
            closeWithDisposeTab.Text = "Close";
            closeWithDisposeTab.Left = closeTab.Left + closeTab.Width;

            Button open = new Button();
            open.Text = "FileOpen";
            open.Left = closeWithDisposeTab.Left + closeWithDisposeTab.Width;

            Button scrollDown = new Button { Text = "Down", Left = closeWithDisposeTab.Left + 250 };
            Button scrollUp = new Button { Text = "Up", Left = closeWithDisposeTab.Left + 330 };

            scrollDown.Click += (s, e) => { browser.Window.ScrollByPages(1); };
            scrollUp.Click += (s, e) => { browser.Window.ScrollByPages(-1); };

            nav.Click += delegate {
                // use javascript to warn if url box is empty.
                if (string.IsNullOrEmpty(urlbox.Text.Trim()))
                    browser.Navigate("javascript:alert('hey try typing a url!');");

                try{
                browser.Navigate(urlbox.Text);
                }catch { }
                tabPage.Text = urlbox.Text;
            };

            newTab.Click += delegate { AddTab(); };

            stop.Click += delegate { browser.Stop(); };

            closeTab.Click += delegate {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            };

            closeWithDisposeTab.Click += delegate
            {
                m_tabControl.Controls.Remove(tabPage);
                tabPage.Dispose();
            };

            open.Click += (s, a) =>
            {
                nsIFilePicker filePicker = Xpcom.CreateInstance<nsIFilePicker>("@mozilla.org/filepicker;1");
                filePicker.Init(browser.Window.DomWindow, new nsAString("hello"), nsIFilePickerConsts.modeOpen);
                filePicker.AppendFilter(new nsAString("png"), new nsAString("*.png"));
                filePicker.AppendFilter(new nsAString("html"), new nsAString("*.html"));
                if (nsIFilePickerConsts.returnOK == filePicker.Show())
                {
                    using(nsACString str = new nsACString())
                    {
                        filePicker.GetFileAttribute().GetNativePathAttribute(str);
                        browser.Navigate(str.ToString());
                    }
                }

            };

            tabPage.Controls.Add(urlbox);
            tabPage.Controls.Add(nav);
            tabPage.Controls.Add(newTab);
            tabPage.Controls.Add(stop);
            tabPage.Controls.Add(closeTab);
            tabPage.Controls.Add(closeWithDisposeTab);
            tabPage.Controls.Add(open);
            tabPage.Controls.Add(browser);
            tabPage.Controls.Add(scrollDown);
            tabPage.Controls.Add(scrollUp);
        }
开发者ID:K-Library-NET,项目名称:dotNET,代码行数:92,代码来源:Main.cs

示例7: GenerateGui


//.........这里部分代码省略.........
                                    {
                                        String name, value;
                                        if (v.Contains(':'))
                                        {
                                            var parts = v.Split(new[] { ':' }, 2);
                                            name = parts[1];
                                            value = parts[0];
                                            description.Add(String.Format(" {0} ({1})", name, value));
                                        }
                                        else
                                        {
                                            name = v;
                                            value = v;
                                        }

                                        items.Add(value);
                                        ((ComboBox)t).Items.Add(name);

                                        if (defaultValue.Equals(value))
                                        {
                                            ((ComboBox)t).SelectedIndex = ((ComboBox)t).Items.Count - 1;
                                        }
                                    }

                                    if (description.Count > 0)
                                    {
                                        if (!String.IsNullOrEmpty(tooltip))
                                            tooltip += Environment.NewLine + Environment.NewLine;
                                        tooltip += "Available options:" + Environment.NewLine +
                                                   String.Join(Environment.NewLine, description);
                                    }
                                    t.Tag = items;

                                    // No default value match
                                    if (((ComboBox)t).SelectedIndex < 0)
                                    {
                                        ((ComboBox)t).DropDownStyle = ComboBoxStyle.DropDown;
                                        t.Text = defaultValue;
                                    }

                                    ((ComboBox)t).SelectedValueChanged += (o, args) =>
                                    {
                                        var c = o as ComboBox;
                                        if (c != null)
                                        {
                                            string v = null;
                                            if (c.Tag != null)
                                            {
                                                var list = c.Tag as List<string>;
                                                if (list != null)
                                                    v = list[c.SelectedIndex];
                                            }

                                            if(v == null)
                                                v = c.SelectedValue.ToString();

                                            config.AddSetting(section, option, v);
                                        }
                                    };
                                }
                            }
                        }

                        if (t == null)
                        {
                            t = new TextBox
                            {
                                Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                                Text = defaultValue /*, Width = (int) (tabControlMain.Width / 1.5)*/
                            };

                            t.TextChanged += (o, args) => { config.AddSetting(section, option, ((TextBox) o).Text); };
                        }

                        panel.SetColumn(t, 1);
                        panel.SetRow(l, i++);
                        panel.Controls.Add(t);

                        if (!String.IsNullOrEmpty(tooltip) && toolTipInfo != null)
                            toolTipInfo.SetToolTip(t, tooltip);

                        lastComment = "";
                    }
                    else
                        lastComment = option;
                }

                if (panel.Controls.Count > 0)
                {
                    panel.AutoScroll = true;
                    page.Controls.Add(panel);
                    tabControlMain.Controls.Add(page);
                }
                else
                {
                    page.Dispose();
                    panel.Dispose();
                }
            }
        }
开发者ID:eried,项目名称:RPiCustomizer,代码行数:101,代码来源:FormEditor.cs

示例8: CloseTab

        public void CloseTab( TabPage tp )
        {
            int index = TabPages.IndexOf( tp );

            ClosingEventArgs args = new ClosingEventArgs( index );
            OnTabClosing( args );
            //Remove the tab and fir the event tot he client
            if ( !args.Cancel )
            {
                // close and remove the tab, dispose it too
                TabPages.Remove( tp );
                OnTabClosed( new ClosedEventArgs( tp, index ) );
                tp.Dispose();
            }
        }
开发者ID:Metapyziks,项目名称:SprytEditor,代码行数:15,代码来源:CanvasTabControl.cs

示例9: DestroyTab

        /* ----------------------------------------------------------------- */
        /// DestroyTab
        /* ----------------------------------------------------------------- */
        public void DestroyTab(TabPage tab)
        {
            if (tab == null) return;
            var parent = tab.Parent as TabControl;
            if (parent == null) return;

            var canvas = CanvasPolicy.Get(tab);
            if (canvas == null) return;
            var engine = canvas.Tag as CanvasEngine;
            if (engine == null) return;

            //engine.Thumbnail = null;
            this.DestroyThumbnail(this.NavigationSplitContainer.Panel1);
            CanvasPolicy.Destroy(canvas);
            if (this.PageViewerTabControl.TabCount > 1) {
                parent.TabPages.Remove(tab);
                tab.Dispose();
            }
        }
开发者ID:cube-soft,项目名称:CubePdfViewer,代码行数:22,代码来源:MainForm.cs

示例10: CloseTabPage

        /// <summary>
        /// Does the actual work to close a tab page, sending out appropriate events and updating
        /// internal structures. Returns true if the page was actually closed.
        /// </summary>
        public bool CloseTabPage(TabPage page)
        {
            if (page == null)
            return false;
              if (TabCount > 1 || CanCloseLastTab)
              {
            TabClosingEventArgs args = new TabClosingEventArgs(page, true, TabPages.IndexOf(page));
            OnTabClosing(args);
            if (args.canClose)
            {
              // The page could be removed in the OnTabClosing event, so prepare for that.
              int tabIndex = TabPages.IndexOf(page);
              if (tabIndex > -1)
              {
            SetBusy(tabIndex, false);

            // Remove this tab and select its predecessor if possible.
            if (SelectedIndex > 0)
              SelectedIndex = SelectedIndex - 1;
            lastTabHit = -1;
            TabPages.Remove(page);
              }

              AdjustLayoutInfo(null);
              Update();

              OnTabClosed(new TabClosedEventArgs(page));

              // In the case OnTabClosed did not dispose of the page do it now.
              if (!page.IsDisposed)
            page.Dispose();

              return true;
            }
              }
              return false;
        }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:41,代码来源:FlatTabControl.cs

示例11: CloseTab

 private static void CloseTab(TabPage tp)
 {
     foreach (Control c in tp.Controls)
     {
         if (c is FileTool)
         {
             if (!FileManager.CloseTool((FileTool) c))
                 break;
         }
     }
     tp.Dispose();
 }
开发者ID:micheleissa,项目名称:dow2-toolbox,代码行数:12,代码来源:MainDialog.cs

示例12: LoadDocument

        private void LoadDocument(string file, Workspace workspace)
        {
            TabPage tab = new TabPage (Path.GetFileNameWithoutExtension (file));
            tab.Name = file; // the key

            // loads and associates the tab page with the document
            Document doc = workspace.CreateDocument (file, tab);
            doc.Services.AddService (typeof (IMenuCommandService), new MenuCommandService (doc.Services));
            doc.Load ();
            doc.Services.AddService (typeof (UndoEngine), new UndoRedoEngine (doc.Services));
            if (doc.LoadSuccessful) {
                doc.Modified += OnDocumentModified;
                workspace.ActiveDocument = doc;
                ((Control)doc.DesignSurface.View).Dock = DockStyle.Fill;
                tab.Controls.Add ((Control)doc.DesignSurface.View);
                surfaceTabs.SuspendLayout ();
                surfaceTabs.TabPages.Add (tab);
                surfaceTabs.ResumeLayout ();
                surfaceTabs.SelectedTab = surfaceTabs.TabPages[file];
            } else {
                MessageBox.Show ("Unable to load!");
                tab.Dispose ();
                workspace.CloseDocument (doc);
            }
        }
开发者ID:himdel,项目名称:mwf-designer,代码行数:25,代码来源:MainView.cs


注:本文中的System.Windows.Forms.TabPage.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。