When my form (AboutForm) is shown I need to hold the focus on this form (the user should only be able to click the OK button) !
Which setting is neccessary in VS2008?
Thanks!
greets leon22
You want to show it modally, so use ShowDialog() rather than Show(). That is all.
For example:
using(var frm = new AboutForm()) {
frm.ShowDialog(this);
}
important: when using ShowDialog, closing the form does not Dispose() it, hence the using; see MSDN:
Unlike modeless forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the Dispose method of the form when the form is no longer needed by your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With