Question How to chenge "Checked" state for DropDownItems

moranka

New member
Joined
Jun 29, 2009
Messages
2
Programming Experience
Beginner
Hi,
I'm trying to learn VB by myself and i have a small problem that i don't know how to solve, maybe someone could give me a hand?

I have ContextMenuStrip with few ToolStripMenuItems
for each ToolStripMenuItem i add dynamically during runtime dropdownitem (ToolStripMenuItem),
when i add the dropdownitem i use something like the following code:
VB.NET:
Dim tmp As New ToolStripMenuItem
tmp.Text = "ABCD"
tmp.Checked = True
ToolStripMenuItem2.DropDownItems.Add(tmp)

my problem is that during run time i cannot change the the "checked" stat, i tried to do something like:
VB.NET:
ToolStripMenuItem2.DropDownItems(0).checked = False
but the checked property is not available for "DropDownItems"
how can i change the "checked" state during runtime?

Thanks in advanced
Moranka
 
Last edited:
DropDownItems returns a ToolStripItem, which is a base class for various types of menu items, you can cast it to type ToolStripMenuItem.
VB.NET:
CType(TestToolStripMenuItem.DropDownItems(0), ToolStripMenuItem).Checked = True
 
Back
Top