bringing modeless dialogs to front

  • Thread starter Thread starter Gregory Khrapunovich
  • Start date Start date
G

Gregory Khrapunovich

I have created a form (Windows Forms) that opens several modeless dialogs.
Sometimes they become covered by other (unrelated) applications and its
annoying to click on each dialog to make them visible again. I would like
all dialogs to become visible when main form becomes visible.

Main form has pointers to each dialog, so I guess all I need is to execute
dlg.BringToFront() for each modeless dialog. The question is when I should
do it. I created Paint event handler for the main form and put these
commands in it. It does the trick but creates other problems, such as main
menu doesn't show up when forms overlap. So where in the main form should I
place dlg.BringToFront() ?

Thank you.
Gregory
 
I would put your code in the Form.GotFocus or Form.Activated (or both)
events, and not the paint event.

Scott
 
When I put this code in the Activate handler, I cannot operate the main form
at all. As for GotFocus, I cannot find this event. Visual Studio doesn't
show it in the form properties.
Gregory
 
Back
Top