當前位置: 首頁>>代碼示例>>C#>>正文


C# UserControl.Dispose方法代碼示例

本文整理匯總了C#中System.Windows.Forms.UserControl.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# UserControl.Dispose方法的具體用法?C# UserControl.Dispose怎麽用?C# UserControl.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.UserControl的用法示例。


在下文中一共展示了UserControl.Dispose方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RemoveControlFromObjectsPanel

        public void RemoveControlFromObjectsPanel(UserControl control)
        {
            if (this.selectedObjectPanels.Contains(control))
            {
                this.selectedObjectPanels.Remove(control);
                this.selectedAssetTabPage.Controls.Remove(control);

                control.Dispose();
                refreshSelectedObjectListView();
            }
        }
開發者ID:nadar71,項目名稱:Krea,代碼行數:11,代碼來源:AssetManagerForm.cs

示例2: Form1_WorkFinished

        private void Form1_WorkFinished(object sender, EventArgs e)
        {
            this.Controls.Remove(currentModule);
            object returnedData = null;
            int Code;
            if ((Code = (currentModule as IGraphLabsModule).GetReturnedCode(out returnedData)) != 0)
            {
                panelSelect.Visible = true;
                currentModule.Dispose();
                currentModule = null;
                MessageBox.Show(this, string.Format("При выполнении модуля \"{0}\" возникла ошибка:\n{1}",
                    dgridSelectedModules.Rows[executingModuleIndex].Cells[1].Value.ToString(),
                    (currentModule as IGraphLabsModule).GetCodeDescription(Code)),
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return;
            }
            currentModule.Dispose();
            currentModule = null;

            executingModuleIndex++;
            if (executingModuleIndex < dgridSelectedModules.Rows.Count)
            {
                try
                {
                    Type moduleType =
                        (AssemblyArray[Int32.Parse(dgridSelectedModules.Rows[executingModuleIndex].Cells[6].Value.ToString())] as Assembly).GetExportedTypes()[0];
                    currentModule = Activator.CreateInstance(moduleType) as UserControl;
                    (currentModule as IGraphLabsModule).WorkFinished += new EventHandler(Form1_WorkFinished);
                    (currentModule as IGraphLabsModule).WorkCanceled += new EventHandler(Form1_WorkCancelled);
                    this.SuspendLayout();
                    currentModule.Location = panelSelect.Location;
                    currentModule.Name = "module";
                    currentModule.Size = panelSelect.Size;
                    currentModule.TabIndex = 0;
                    this.Controls.Add(currentModule);
                    (currentModule as IGraphLabsModule).InitModule(returnedData);
                    DisplayModuleInfo();
                    this.ResumeLayout(false);

                }
                catch (Exception E)
                {
                    MessageBox.Show(E.ToString());
                    executingModuleIndex = -1;
                    panelSelect.Visible = true;
                    if (currentModule != null)
                    {
                        if (Controls.Contains(currentModule))
                            Controls.Remove(currentModule);
                        currentModule.Dispose();
                        currentModule = null;
                    }
                }
            }
            else
            {
                executingModuleIndex = -1;
                panelSelect.Visible = true;
                ResizeOnModuleFinish();
            }
        }
開發者ID:svtz,項目名稱:GraphLabs,代碼行數:63,代碼來源:mainForm.cs

示例3: CleanupButton

        private void CleanupButton(UserControl button)
        {
            button.Parent = null;

            button.MouseDown -= new MouseEventHandler(button_MouseDown);
            button.MouseMove -= new MouseEventHandler(button_MouseMove);
            button.MouseUp -= new MouseEventHandler(button_MouseUp);
            Controls.Remove(button);
            button.Dispose();
        }
開發者ID:china-vo,項目名稱:wwt-windows-client,代碼行數:10,代碼來源:ButtonGroupControl.cs

示例4: btnRun_Click

        private void btnRun_Click(object sender, EventArgs e)
        {
            if (dgridSelectedModules.Rows.Count == 0)
            {
                MessageBox.Show(this, "Необходимо выбрать хотя бы один модуль.",
                     "",
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Warning);
                return;
            }

            if (dgridSelectedModules.Rows.Count > 1)
                for (int i = 1; i < dgridSelectedModules.Rows.Count; i++)
                {
                    if (dgridSelectedModules.Rows[i].Cells[5].Value.ToString() !=
                        dgridSelectedModules.Rows[i-1].Cells[4].Value.ToString())
                    {
                        MessageBox.Show(this, "Неверная последовательность модулей.\nЗапуск невозможен.",
                            "",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning);
                        return;
                    }
                }

            panelSelect.Visible = false;
            executingModuleIndex = 0;
            try
            {
                Type moduleType =
                    (AssemblyArray[Int32.Parse(dgridSelectedModules.Rows[executingModuleIndex].Cells[6].Value.ToString())] as Assembly).GetExportedTypes()[0];
                currentModule = Activator.CreateInstance(moduleType) as UserControl;
                (currentModule as IGraphLabsModule).WorkFinished += new EventHandler(Form1_WorkFinished);
                (currentModule as IGraphLabsModule).WorkCanceled += new EventHandler(Form1_WorkCancelled);
                this.SuspendLayout();
                if (typeof(IModuleSettings).IsAssignableFrom(moduleType))
                {
                    UserControl settingsControl = ((IModuleSettings)currentModule).GetSettingsControl(null) as UserControl;
                    settingsControl.Location = panelSelect.Location;
                    settingsControl.Name = "settings";
                    settingsControl.Size = panelSelect.Size;
                    settingsControl.TabIndex = 0;
                    (settingsControl as ISettingsControl).SettingsSet += new SettingsEventHandler(mainForm_SettingsSet);
                    (settingsControl as ISettingsControl).SettingsNotSet += new SettingsEventHandler(mainForm_SettingsNotSet);
                    this.Controls.Add(settingsControl);
                    oldHeight = Height;
                    oldWidth = Width;
                }
                else
                {
                    currentModule.Location = panelSelect.Location;
                    currentModule.Name = "module";
                    currentModule.Size = panelSelect.Size;
                    currentModule.TabIndex = 0;
                    (currentModule as IGraphLabsModule).InitModule(typeof(void));
                    this.Controls.Add(currentModule);
                    oldHeight = Height;
                    oldWidth = Width;
                }
                this.ResumeLayout();
                FormBorderStyle = FormBorderStyle.Sizable;
                statusStrip.SizingGrip = true;
                DisplayModuleInfo();
                новаяПоследовательностьЗапускаToolStripMenuItem.Enabled =
                    открытьПоследовательностьЗапускаToolStripMenuItem.Enabled =
                    добавитьВКонецПоследовательностиToolStripMenuItem.Enabled =
                    удалитьИзПоследовательностиToolStripMenuItem.Enabled =
                    передвинутьВверхToolStripMenuItem.Enabled =
                    передвинутьВнизToolStripMenuItem.Enabled =
                    добавитьНовыйМодульВБазуToolStripMenuItem.Enabled =
                    выполнитьПоследовательностьToolStripMenuItem.Enabled =
                    сохранитьПоследовательностьЗапускаToolStripMenuItem.Enabled =
                    сохранитьПоследовательностьЗапускаКакToolStripMenuItem.Enabled = false;
                прерватьВыполнениеToolStripMenuItem.Enabled = true;
            }
            catch
            {
                executingModuleIndex = -1;
                panelSelect.Visible = true;
                if (currentModule != null)
                {
                    if (Controls.Contains(currentModule))
                        Controls.Remove(currentModule);
                    currentModule.Dispose();
                    currentModule = null;
                }
            }
        }
開發者ID:svtz,項目名稱:GraphLabs,代碼行數:88,代碼來源:mainForm.cs

示例5: CleanupButton

        private void CleanupButton(UserControl button)
        {
            button.Parent = null;

            button.MouseDown -= button_MouseDown;
            button.MouseMove -= button_MouseMove;
            button.MouseUp -= button_MouseUp;
            Controls.Remove(button);
            button.Dispose();
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:10,代碼來源:ButtonGroupControl.cs


注:本文中的System.Windows.Forms.UserControl.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。