本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
}
}
示例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();
}