Results 1 to 4 of 4

Thread: Menu Items [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131

    Menu Items [RESOLVED]

    Here is my menu

    I want to click Red and have a check by it only. The when I click Yellow have a check by it only.

    When I write my click event like this: mnuRed.Checked = True
    It will check it but will not uncheck Blue.
    Last edited by twisted; Jun 24th, 2004 at 09:23 AM.
    Twisted

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131
    I wrote it like this:

    VB Code:
    1. Private Sub mnuGreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGreen.Click
    2.         mnuGreen.Checked = True
    3.         mnuBlue.Checked = False
    4.         mnuRed.Checked = False
    5.         mnuYellow.Checked = False
    6.         Me.BackColor = System.Drawing.Color.Green
    7.     End Sub

    Is there any easier way??
    Twisted

  3. #3
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Yes, you can create a variable that holds the index of the currently selected menuitem and then uncheck just that menu when you are selecting a new menuitem.

    Lets say you have a menu named mnuColors and that has 4 MenuItems on it

    In your mnuClick code you can code it like this

    VB Code:
    1. Private mnuSelIndx As Int32
    2.     Private Sub mnuGreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGreen.Click
    3.         mnuColor.MenuItems(mnuSelIndx).Checked = False
    4.         mnuGreen.Checked = True
    5.         mnuSelIndx = mnuGreen.Index
    6.         Me.BackColor = System.Drawing.Color.Green
    7.     End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131
    Thanks!
    Twisted

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