How to change the checked state of a ToolStripItem in Winforms?

Joan Venge picture Joan Venge · Oct 21, 2011 · Viewed 14.8k times · Source

When I look it up, they list it as having a .Checked property. But both in Visual Studio and on msdn, it doesn't list any kid of Checked property.

ContextMenuStrip menu = new ContextMenuStrip ( );
var menuItem = menu.Items.Add ( "CheckedItem" );
//menuItem.Checked?

Is there a way to do this?

Answer

Jeff Ogata picture Jeff Ogata · Oct 21, 2011

You need to cast to ToolStripMenuItem:

((ToolStripMenuItem)menuItem).Checked = true;