VB.Net - How do i keep a form on top of others

The Form class represents a window within an application. This includes dialog boxes, modeless windows, and Multiple Document Interface client and parent windows. In VB6 you can use a Win32API call to SetWindowPos to get a form to always stay on top. This has been simplified in VB.NET by setting Form's TopMost property as TRUE.

 

Dim frm As New Form2

frm.TopMost = True

frm.Show()

 

A topmost form is a form that overlaps all the other forms even if it is not the active or foreground form. You can use this property to create a form that is always displayed in your application, such as a MessageBox window.

 

Public Class Form1
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim frm As New Form2
    frm.TopMost = True
    frm.Show()
  End Sub
End Class

Next Post Previous Post
No Comment
Add Comment
comment url