如果对话框结果正常,则关闭父窗口
本文关键字:窗口 对话框 结果 如果 | 更新日期: 2023-09-27 18:35:17
目前我正在编写一个应用程序,该应用程序有一个窗口,用于确认用户是否已完成编辑数据并让他们对编辑发表评论。用户可以确认或取消编辑。我想在子窗体对话框结果正常时关闭父窗体,如果数据被取消,则刷新数据。结果正确传递,但它仍然没有关闭父窗体。
我用了ds。窗体关闭其他视图以运行引用。
我正在打开一个使用以下代码的子窗体。
View ds = new View ();
ds.userID = userID;
ds.localID= localID;
ds.FormClosed += ChildFormClosed; // i use this line to call a function when the child form is close
DialogResult dialogResult = new DialogResult(); // fetches the Dialog Result
dialogResult = ds.ShowDialog(); // opens the view
if (dialogResult != DialogResult.OK) // checks if the Dialog Result is OK
this.Close();
if (dialogResult != DialogResult.OK) // checks if the Dialog Result is OK
不,它不检查对话框结果是否OK
,它检查是否未OK
。
这样做:
if (dialogResult == DialogResult.OK)
在我看来
,您无法关闭主窗体并打开子窗体。
如果主窗体关闭,则应用程序关闭,程序无法打开新的子窗体。
也许那没有报告。
对不起我的英语。