Javatpoint Logo
Javatpoint Logo

How to keep a Form on top of others in VB.NET?

When we create a Windows application, we want to keep the main form on top of another form. We can also say that when the application starts, a popup window form is displayed on top of the main form within the application to start the further process. In VB6 we can see a Win32API that call SetWindowPos to set the form always on top. And in VB.NET, it is simple to keep a form at the top using the TopMost property of the form as True. After setting the TopMost property to true, the Uppermost form of a Windows application that overlaps all other forms, even if the Uppermost form is not in the active or foreground form.

Furthermore, the TopMost property of the form will force the form to the top layer of the screen when the value of TopMost is true. And the Show() method is used to display the form in Windows Application.

The following syntax is used to set the form on top of others.

If we want to display a form on top of another form, we have to create two Windows Forms.

  1. MainPage.vb
  2. TopForm.vb

To keep the TopForm.vb Form on top of the MainPage.vb Form, we need to set the TopMost property in the MainPage.vb file to True.

MainPage.vb

TopForm.vb

Output:

How to keep a Form on top of others in VB.NET

In the above image, the TopForm is placed at the top of the 'javatppoint.com' (MainPage). If we close the TopForm, it shows the form, shown below.

How to keep a Form on top of others in VB.NET

Provide the detail in the Student Registration form and click on the Submit button.

How to keep a Form on top of others in VB.NET

After Clicking on the Submit button, it shows a popup message on the top of the MainPage.vb file or javatpoint.com Form.

How to keep a Form on top of others in VB.NET
Next Topic#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA