Form .ShowDialog () does not show form
I ran into a situation where I am trying to run a simple line of code in a method
Dim res As DialogResult = frmOptions.ShowDialog ()
but nothing happens. The dialog box will not appear. If I run this method from somewhere else in the code, it will execute fine (i.e., display the form interactively and the code is fine after that). Hence, it might be the way I ended up with this code that is causing my problem, but I can't see to find what is wrong.
When I pause the debugger, the line of code is highlighted in green, but I don't see any way to step over or into it.
Any idea what might be causing this, or what I should be looking for might be causing the problem?
Thanks for the help!
a source to share
The problem was that the active window, set as the default owner of the dialog, has a TopMost property set to true. As a result, the dialog box was displayed behind the owner's window (TopMost).
The dialog box is a modal form, since other windows cannot be selected, so the program appears as nothing that happens or works when in fact the dialog box is simply hidden behind the topmost form.
The reason the code works in other cases is that the active window, when the dialog is loaded, does not have the TopMost property set to true, thus displaying the dialog as expected.
a source to share