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.
Printable View
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.
I wrote it like this:
VB Code:
Private Sub mnuGreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGreen.Click mnuGreen.Checked = True mnuBlue.Checked = False mnuRed.Checked = False mnuYellow.Checked = False Me.BackColor = System.Drawing.Color.Green End Sub
Is there any easier way??
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:
Private mnuSelIndx As Int32 Private Sub mnuGreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGreen.Click mnuColor.MenuItems(mnuSelIndx).Checked = False mnuGreen.Checked = True mnuSelIndx = mnuGreen.Index Me.BackColor = System.Drawing.Color.Green End Sub
Thanks!