Results 1 to 6 of 6

Thread: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    15

    Post VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    How do I make a 'TopMost' toggle button with a checkbox in VB.net?

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,268

    Re: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    A checkbox's value comes from the Checked property. The Checked property is a boolean value (documentation). The TopMost property is also a boolean value (documentation).

    All you need to do is:
    1. Handle CheckedChanged event of the Checkbox (documentation)
    2. Set the TopMost property equal to the Checked property


    Code:
    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        TopMost = DirectCast(sender, CheckBox).Checked
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    15

    Re: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    Sorry, how does this work? Will this allow me to 'toggle' TopMost on and off with a 'check' next to the button/menu item when 'on' or 'off'? I may have worded it completely wrong, so apologies if I have so.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,976

    Re: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    If you think you havenít described it accurately, perhaps you need to explain the situation more clearly... Where does the menu come into it?

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,976

    Re: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    TopMost refers to the z-order of controls. Do you mean the top item in a menu???

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    106,913

    Re: VB.Net - How do I make a 'TopMost' toggle button with a checkbox?

    Quote Originally Posted by JakeC View Post
    Will this allow me to 'toggle' TopMost on and off with a 'check' next to the button/menu item when 'on' or 'off'?
    Maybe you could try it and see for yourself. Your arms aren't painted on. The reason you weren't just given code to copy and paste in the first place was so you would put some thought and effort into the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width