Link to home
Start Free TrialLog in
Avatar of LoGa1234567890
LoGa1234567890

asked on

No 'check' property for Menustrip DropDownItems created at runtime

Hi experts,

I need to add an array of menu dropdownitem at runtime to a menuitem created at design time.
The problem is: I can't find the property ‘check’  in my array of dropdownitem in its click event. I want the fired dropdownitem checked and all other dropdownitem in the same array uncheched.

Below is my code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For X = 0 To 5
            Dim NewMenuItem As New ToolStripMenuItem("Option" & X + 1, Nothing, New EventHandler(AddressOf Option_Click))
            NewMenuItem.Tag = X
            OptionToolStripMenuItem.DropDownItems.Add(NewMenuItem)
        Next
    End Sub

    Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For X = 0 To OptionToolStripMenuItem.DropDownItems.Count - 1
            OptionToolStripMenuItem.DropDownItems(X).BackColor = Color.White
          'want check property instead of highlighted with color
        Next
        OptionToolStripMenuItem.DropDownItems(sender.tag).BackColor = Color.Blue
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of louisfr
louisfr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LoGa1234567890
LoGa1234567890

ASKER

Thank you !