TopMost - affects realtime?

  • Thread starter Thread starter Rob R. Ainscough
  • Start date Start date
R

Rob R. Ainscough

Suppose I have a form that loads with TopMost = True. If I change the form
to TopMost = False will it immediately affect the form -- in other words is
TopMost dynamic? The reason I ask is that I want to disable TopMost when
I'm displaying a Msgbox (otherwise the message box appears behind my form).

Rob.
 
Rob R. Ainscough said:
Suppose I have a form that loads with TopMost = True. If I change the form
to TopMost = False will it immediately affect the form -- in other words is
TopMost dynamic? The reason I ask is that I want to disable TopMost when
I'm displaying a Msgbox (otherwise the message box appears behind my form).

Yes, TopMost works immediately. If you want to ensure the other form you
are showing appears above the current form, you can:

Form form = new Form();
form.Text = "Test";
this.TopMost = false;
form.ShowDialog();
this.TopMost = true;

Note that if you show the other form with the Show() method instead of
ShowDialog(), then the "this.TopMost = true" line will execute immediately,
and your other form will not appear above your main form. In this case, the
only way to ensure the other form appears on top is to set its TopMost
property to true.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top