How do I set a submenu DropDownItem to CHECKED without Clicking on it?

230 views Asked by At

I've created a contextmenu (ie displays on a right mouse click) at design time with 2 menu items. I'm subsequently using code to add submenu items eg. For the 2nd menu item I add the following 4 submenu items.

     (contextMenuStrip1.Items[1] as ToolStripMenuItem).DropDownItems.Add("1", null, Scale_Click);
     (contextMenuStrip1.Items[1] as ToolStripMenuItem).DropDownItems.Add("2", null, Scale_Click);
     (contextMenuStrip1.Items[1] as ToolStripMenuItem).DropDownItems.Add("4", null, Scale_Click);
     (contextMenuStrip1.Items[1] as ToolStripMenuItem).DropDownItems.Add("8", null, Scale_Click);

But say I want to have the 3rd submenu item initially checked (ie. has a tick beside it when the user views it). How do I do that? I thought it would be simple but I'm finding its not and Id be pulling my hair out if I had any. I was thinking it would be along the lines of;

((ToolStripMenuItem)contextMenuStrip1.Items[1]).DropDownItems[2].Checked = true;

but that's invalid.

0

There are 0 answers