I’ve written a relatively large application with lots of dialog boxes and forms, etc.
I’m opening them with Form.ShowDialog().
A lot of the time, the forms open behind existing windows, e.g. yesterday I was testing it on a machine with several other programs open: many Windows Explorer windows, a few Excel windows, etc. A lot of my forms, open/save file dialogs, etc were supposed to open but didn’t. I was twiddling my thumbs until I pressed alt+tab and realised that they were, in fact, behind another window.
Why is this happening, and how can I stop it in future? Thanks.
Use the
ShowDialogoverride which takes an owner window as a parameter.By passing in your main window as the dialog’s owner, you guarantee that the dialog always pops in front of it, and stays in front of it.
And it won’t annoy the user if they were using some other application.