子表单(由父表单code 1
调用),名称为call_order
。在按钮单击功能中,我使用DataBase并设置Get_Result
返回父表单的局部变量。我认为它不是关于我的代码,问题必须在别的地方,但我无法找到它,如果你有一个想法欣赏。同样在keydown
的{{1}}函数中我检查过,如果密钥为call_order
,则escape
假设在用户按this.close();
时关闭表单。
escape
在call_order表格的按钮点击功能中我有:
code1: in parent form
if (e.KeyCode == Keys.F12) {
call_order call_order = new call_order(today_sale);
call_order.ShowDialog();
today_sale = Convert.ToInt64(call_order.Get_Result);
}
@ Hans Passant,在调用堆栈中执行此操作(我从第一次调用子窗体)。但我无法理解为什么窗体是关闭的,它的所有汇编引用。你明白为什么吗?
if (shomare_eshterake_user != "")
{
int success = save_one_sale();
if (success == 1)
{
MessageBox.Show("something");
shomare_moshtari_fish.Text = Convert.ToString(shomare_fish_phone_user);
docPrint.Print();
shomare_moshtari_fish.Text = Convert.ToString(shomare_fish_phone_user + 1);
}
else if (success == 0)
{
MessageBox.Show("something");
}
else if (success == 3)
{
nan_barbari_count.Text = "0";
nan_tafton_count.Text = "0";
nan_mahali_count.Text = "0";
nan_barbari_count.Focus();
nan_barbari_count.SelectAll();
}
else if (success == 5)
{
MessageBox.Show("something");
}
}
else MessageBox.Show("something");
答案 0 :(得分:1)
您是否在该按钮上设置了DialogResult属性?
来自MSDN上的Button.DialogResult
页:
If the DialogResult for this property is set to anything other than None, and if
the parent form was displayed through the ShowDialog method, clicking the button
closes the parent form without your having to hook up any events.