如何在Windows窗体中创建表单模式?

时间:2022-08-25 23:58:15

I'm trying to create a child form that helps the user to enter data for a field in the parent form. I want this child form to be modal, but what do I need to do to make this form modal?

我正在尝试创建一个子表单,帮助用户输入父表单中字段的数据。我希望这个子窗体是模态的,但是我需要做什么才能使这个窗体模态化?

Is there's a different type of item I need to use?

我需要使用不同类型的物品吗?

4 个解决方案

#1


35  

Use Form.ShowDialog()

使用Form.ShowDialog()

As Bob mentioned, you should set Form.DialogResult accordingly on your modal form.

正如Bob所提到的,你应该在你的模态表单上相应地设置Form.DialogResult。

#2


14  

Use the ShowDialog() method instead of Show() when you display the child form.

显示子窗体时,请使用ShowDialog()方法而不是Show()。

#3


8  

Form f = new Form();
f.ShowDialog(this);

#4


4  

Call the ShowDialog method.

调用ShowDialog方法。

Form f = new Form();
f.ShowDialog(this);

For more info click this https://msdn.microsoft.com/en-us/library/aa984358(v=vs.71).aspx

欲了解更多信息,请点击此https://msdn.microsoft.com/en-us/library/aa984358(v=vs.71).aspx

#1


35  

Use Form.ShowDialog()

使用Form.ShowDialog()

As Bob mentioned, you should set Form.DialogResult accordingly on your modal form.

正如Bob所提到的,你应该在你的模态表单上相应地设置Form.DialogResult。

#2


14  

Use the ShowDialog() method instead of Show() when you display the child form.

显示子窗体时,请使用ShowDialog()方法而不是Show()。

#3


8  

Form f = new Form();
f.ShowDialog(this);

#4


4  

Call the ShowDialog method.

调用ShowDialog方法。

Form f = new Form();
f.ShowDialog(this);

For more info click this https://msdn.microsoft.com/en-us/library/aa984358(v=vs.71).aspx

欲了解更多信息,请点击此https://msdn.microsoft.com/en-us/library/aa984358(v=vs.71).aspx