Results 1 to 3 of 3

Thread: MenuItem problem [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    MenuItem problem [Resolved]

    I am having a problem with getting a menu item to check or uncheck. Any suggestions on what's going wrong with this? It obviously keeps the form on top of other windows when I can get it working.

    Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click

    If MenuItem3.Checked = False Then

    Me.TopMost = False

    Else

    MenuItem3.Checked = True

    Me.TopMost = True

    End If

    End Sub



    Thanks in advance for those that reply
    Last edited by teamdad; Jun 13th, 2004 at 08:17 PM.

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I think your problems is, that you check wether the item is checked. if not you don't do any thing to the item.
    If it is checked, you set to checked, which it allready is. So that way, it will allways be checked.

    Try changing your code to this.

    VB Code:
    1. Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
    2.  
    3. 'Toggle the state of the item
    4. MenuItem3.Checked=Not MenuItem3.Checked
    5.  
    6. If MenuItem3.Checked = False Then
    7.  
    8. Me.TopMost = False
    9.  
    10. Else
    11.  
    12. Me.TopMost = True
    13.  
    14. End If
    15.  
    16. End Sub
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60

    Talking

    Or you could make that a little bit simpler...
    VB Code:
    1. Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
    2.  
    3. 'Toggle the state of the item
    4. MenuItem3.Checked=Not MenuItem3.Checked
    5.  
    6. Me.TopMost = MenuItem3.Checked
    7.  
    8. End Sub

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