【发布时间】:2013-03-14 23:01:12
【问题描述】:
请帮助我解决此表单在按钮执行单击后关闭火灾的问题,因为我只依赖 Windows 关闭按钮(右上角),我不使用附加按钮来关闭表单。 然而,这个程序仍在工作,但在保存 .ini 文件后不会立即自动关闭表单..
我想关闭表单...在 button1.performclick() 之后,但我不知道该怎么做..
我有以下代码:
int beFore, afTer;
private void Form3_Load(object sender, EventArgs e)
{
beFore = this.checkedListBox1.CheckedIndices.Count +
this.checkedListBox2.CheckedIndices.Count +
this.checkedListBox3.CheckedIndices.Count +
this.checkedListBox4.CheckedIndices.Count;
}
//private Form4 subForm4 = new Form4();
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
afTer = this.checkedListBox1.CheckedIndices.Count +
this.checkedListBox2.CheckedIndices.Count +
this.checkedListBox3.CheckedIndices.Count +
this.checkedListBox4.CheckedIndices.Count;
while (beFore != afTer)
{
if (MessageBox.Show("Changes have been made..\r\nSave to configuration file (.ini) ?", "Warning",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.button1.PerformClick(); //need to close this form after button.performclick..
this.UpdateForm1();
break;
}
else
{
this.UpdateForm1();
break;
}
}
beFore = afTer;
}
private void UpdateForm1()
{
Form4 subForm4 = new Form4();
subForm4.Show();
subForm4.Update();
try
{
int checkagain1 = this.checkedListBox1.CheckedIndices.Count; this.checkedListBox1.SetItemChecked(2, true);
int checkagain2 = this.checkedListBox2.CheckedIndices.Count; this.checkedListBox2.SetItemChecked(2, true);
int checkagain3 = this.checkedListBox3.CheckedIndices.Count; this.checkedListBox3.SetItemChecked(2, true);
int checkagain4 = this.checkedListBox4.CheckedIndices.Count; this.checkedListBox4.SetItemChecked(2, true);
Form1 myParentForm = (Form1)this.Owner;
if (myParentForm.comboBox1.Text.Length != 0)
{
//myParentForm.Enabled = false;
myParentForm.method1();
myParentForm.method2();
myParentForm.method3();
myParentForm.method4();
//myParentForm.Enabled = true;
subForm4.Close();
}
}
catch (Exception)
{
subForm4.Close();
return;
throw;
}
}
【问题讨论】:
-
如果您希望人们帮助您,请在格式化您的代码方面付出更多努力。我可以理解英语很可能是您的第二语言,但您很难理解并且问题不清楚。
-
对不起,朋友,但您根本不清楚您要做什么。我们看到了代码,模糊地理解了您所说的关于单击某些按钮时关闭表单的含义,但您并没有清楚地解释您想要什么。跨度>
标签: c#