0

In my software, I am showing a form using form.Show(). This form should be on top, for that I am using -

form.TopMost = true;

When I open other applications while my software is still running, this inner form is shown on top of other applications too.

I need to use form.Show() because I want other parts of master form accessible while inner form is shown. So I can't use form.ShowDialog(). Not duplicate of How can I bring my application window to the front?

Community
  • 1
  • 1
Arpit Gupta
  • 1,209
  • 1
  • 22
  • 39

2 Answers2

0

The only really robust technique was suggested in this answer, as follows.

form.WindowState = FormWindowState.Minimized;
form.Show();
form.WindowState = FormWindowState.Normal;
Community
  • 1
  • 1
Zoltán Tamási
  • 12,249
  • 8
  • 65
  • 93
0

Answering my own question- To achieve the above purpose, there is a need of creating an owned window by displaying it with the Show(owner) overload. Or by explicitly assigning its Owner property. No need to keep form.TopMost = true. Instead, It should be -

form.TopLevel = true; //Its true by default.
form.Show(this);
Arpit Gupta
  • 1,209
  • 1
  • 22
  • 39