Reputation: 1162
I'm trying to make sort of a selector/last detector in my menustrip. Essentially I have a bunch of "sub items" under one menu strip item. And I want to go through all of them, uncheck them, and then check only the one that was clicked.
Essentially I want to uncheck all of the stuff that starts with de_ (and that last one, so all of them)
Edit: Got it to work, here is the code I ended up using
private void ItemClick(object sender, EventArgs e)
{
foreach (ToolStripMenuItem item in mapsToolStripMenuItem.DropDownItems)
{
item.Checked = false;
}
((ToolStripMenuItem)sender).Checked = true;
}
But I'm not sure what to replace that ? with in order to look into the right place.
Upvotes: 2
Views: 2476
Reputation: 81675
Try using the parent menu's DropDownItems collection:
foreach (ToolStripMenuItem item in mapStripMenuItem.DropDownItems ) {
item.Checked = false;
}
From you image, it should be named Map-something, I'm guessing.
Upvotes: 3