none
How to make my Form in vb.net stayin top of other windows?

    Question

  • HI,

    I have a form in vb.net with a checkbox and I want it to stay in top of other windows if the user checks the checkbox and not to stay in top of other windows when the checkbox is not checked


    Regards Rimzy
    Saturday, June 26, 2010 7:04 PM

Answers

  • this might work for you; this is in a Button Click event on Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm2New As New Form2
        If CheckBox1.Checked Then
          Me.TopMost = True
        End If
        frm2New.Show()
      End Sub
    • Marked as answer by Rimzy Monday, June 28, 2010 4:11 PM
    Saturday, June 26, 2010 7:16 PM
  • Use Me.TopMost = True/False in the CheckBox event to make the current form stay or not stay on Top.

    Something like:

    Me.TopMost = Me.CheckBox1.Checked


    Regards from Livingston, Scotland
    • Marked as answer by Rimzy Monday, June 28, 2010 4:11 PM
    Saturday, June 26, 2010 7:17 PM

All replies

  • this might work for you; this is in a Button Click event on Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm2New As New Form2
        If CheckBox1.Checked Then
          Me.TopMost = True
        End If
        frm2New.Show()
      End Sub
    • Marked as answer by Rimzy Monday, June 28, 2010 4:11 PM
    Saturday, June 26, 2010 7:16 PM
  • Use Me.TopMost = True/False in the CheckBox event to make the current form stay or not stay on Top.

    Something like:

    Me.TopMost = Me.CheckBox1.Checked


    Regards from Livingston, Scotland
    • Marked as answer by Rimzy Monday, June 28, 2010 4:11 PM
    Saturday, June 26, 2010 7:17 PM