What will be the Visual Basic code for the Always On Top option?

I have the Always On Top Tool Strip Menu option, and I can’t determine the code that will make it stay on top of other windows when checking, and vice versa if it is not installed. Could you help me?

+5
source share
5 answers

To set "always on top", install myForm.TopMost = Truein your menu item. See Form.TopMost Documentation .

To install it again, install myForm.TopMost = False.

+12
source

To toggle whether Form TopMost, just change the property Form.TopMost.

For example, to set the form at the top, use the following command:

Form.TopMost = True

TopMost, :

Form.TopMost = False
+6

, , , . , chkAlwaysOnTop, . , .

Private Sub chkAlwaysOnTop_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkAlwaysOnTop.CheckedChanged
    Me.TopMost = chkAlwaysOnTop.Checked            
End Sub

, , :

Private Sub MainActivity_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    My.Settings.AlwaysOnTop = chkAlwaysOnTop.Checked
    My.Settings.Save()
End Sub

:

 Me.TopMost = My.Settings.AlwaysOnTop
 chkAlwaysOnTop.Checked = My.Settings.AlwaysOnTop

, , : Rubber Stamp ( )

+3

:

Me.TopMost = true 

false.

0

, :

TopMost = CheckBox1.Checked

, CheckBox1 , .

0
source

All Articles