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.Dr opDownItem s.Add(NewM enuItem)
Next
End Sub
Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
For X = 0 To OptionToolStripMenuItem.Dr opDownItem s.Count - 1
OptionToolStripMenuItem.Dr opDownItem s(X).BackC olor = Color.White
'want check property instead of highlighted with color
Next
OptionToolStripMenuItem.Dr opDownItem s(sender.t ag).BackCo lor = Color.Blue
End Sub
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"
NewMenuItem.Tag = X
OptionToolStripMenuItem.Dr
Next
End Sub
Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
For X = 0 To OptionToolStripMenuItem.Dr
OptionToolStripMenuItem.Dr
'want check property instead of highlighted with color
Next
OptionToolStripMenuItem.Dr
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER