09/01/2014 by Nitesh

How to Dock/Display Windows Form on Top of all Applications on Desktop

Friends,

Most of us have seen and used TeamViewer. When TeamViewer starts, it displays a small window at the right bottom of the Desktop that remains on top of all the applications that we open on our computer. The TeamViewer icon looks something similar to the image shown below.
TV
You can achieve this feature in Windows Form using a very small line of code. To set the form as the top most form of all running applications, you need to set the Form’s TopMost property as True. As Per MSDN, TopMost “Gets or sets a value indicating whether the form should be displayed as a topmost form”.

You can set this property of the form at design time as well as run-time. To set the property at Design time, follow the below steps –

  • Select the Form
  • Hit F4 to display Form’s properties.
  • Select TopMost and change the value to True.

To change this property at run-time, you can simply write the below code –
C#

this.TopMost=true;

VB.Net

Me.TopMost=True

Hope this little bit of information saves your time. Cheers!

#C##VB.Net#Winforms