本文整理汇总了C#中System.Windows.Forms.MenuItem.RadioCheck属性的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.RadioCheck属性的具体用法?C# MenuItem.RadioCheck怎么用?C# MenuItem.RadioCheck使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem.RadioCheck属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureMyMenus
// This method is called from the constructor of the form to set up the menu items.
public void ConfigureMyMenus()
{
/* Set all of these menu items to Radio-Button check marks so the user can see
that only one color can be selected at a time. */
menuItemRed.RadioCheck = true;
menuItemBlue.RadioCheck = true;
menuItemGreen.RadioCheck = true;
}
// The following event handler would be connected to three menu items.
private void MyMenuClick(Object sender, EventArgs e)
{
if(sender == menuItemBlue)
{
// Set the checkmark for the menuItemBlue menu item.
menuItemBlue.Checked = true;
// Uncheck the menuItemRed and menuItemGreen menu items.
menuItemRed.Checked = false;
menuItemGreen.Checked = false;
// Set the color of the text in the TextBox control to Blue.
textBox1.ForeColor = Color.Blue;
}
else if(sender == menuItemRed)
{
// Set the checkmark for the menuItemRed menu item.
menuItemRed.Checked = true;
// Uncheck the menuItemBlue and menuItemGreen menu items.
menuItemBlue.Checked = false;
menuItemGreen.Checked = false;
// Set the color of the text in the TextBox control to Red.
textBox1.ForeColor = Color.Red;
}
else
{
// Set the checkmark for the menuItemGreen menu item.
menuItemGreen.Checked = true;
// Uncheck the menuItemRed and menuItemGreen menu items.
menuItemBlue.Checked = false;
menuItemRed.Checked = false;
// Set the color of the text in the TextBox control to Blue.
textBox1.ForeColor = Color.Green;
}
}