BringToFront() in C#

form.TopMost = true;
form.ShowDialog();
form.BringToFront();

Should work with all applications, full-screen exclusive games included (tested on all my games, so far, it works).


You could try setting the notification form's TopMost property to true...or make it modal by calling .ShowDialog instead of .Show.


I struggled with the same topic, especially when a "link" to a custom protocol was clicked in Outlook. (The App catched it, but always in the background...)

Even though a lot of solutions worked while debugging, for the "Live-Deployment" only the following chain of calls seems to achieve what was desired:

(Invoked, cause handling of links happens from a thread)

this.Invoke(new Action(() => {
  this.Activate();
  //...do stuff
  this.TopMost = true;
  this.BringToFront();
  this.TopMost = false;                              
}));

Works about every time.

Tags:

C#

.Net

Winforms