I have a Main Form and a Other Form.
The Main Form is always open, and at some time it will launch Other Form.
I tried:
form.TopMost = true;
But this only places the form on top. The Form behind (Main Form) still can be accessible.
How can I get the same behavior like when I do OpenFileDialog, and disable the main form behind it?
(Thanks in advance)
You need to make your form modal. To do this, use
ShowDialoginstead ofShowto display it (the same way you do with a dialog).Also, note that forms shown with
ShowDialogare not actually closed and disposed when you click their Close button, so you should dispose them manually. The usual way to handle their lifetime is to use ausingconstruct: