Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

MenuItem.RadioCheck Property

Gets or sets a value indicating whether the MenuItem, if checked, displays a radio-button instead of a check mark.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public bool RadioCheck { get; set; }
/** @property */
public boolean get_RadioCheck ()

/** @property */
public void set_RadioCheck (boolean value)

public function get RadioCheck () : boolean

public function set RadioCheck (value : boolean)

Property Value

true if a radio-button is to be used instead of a check mark; false if the standard check mark is to be displayed when the menu item is checked. The default is false.

Check marks do not necessarily imply a mutually exclusive state for a group of menu items. You can use this property to indicate to the user that the check mark of a menu item is mutually exclusive.

The following code example uses the Checked property to change the state of an application. In the example, a group of menu items are provided that are used to specify the color for the text in an TextBox control. In the example, the event handler provided is used by the Click event of the three menu items. Each menu item specifies a color, menuItemRed, menuItemGreen, or menuItemBlue. The event handler determines which menu item was clicked, places a checkmark to the selected menu item, and changes the text color of the form's TextBox control, named textBox1. The example also uses the RadioCheck property to demonstrate how a radio-button check is used to show menu items that are mutually exclusive. This example requires that the System.Drawing namespace has been added to the form that contains this code.

// 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;
   }
}


// 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.set_RadioCheck(true);
    menuItemBlue.set_RadioCheck(true);
    menuItemGreen.set_RadioCheck(true);
} //ConfigureMyMenus

// The following event handler would be connected to three menu items.
private void MyMenuClick(Object sender, EventArgs e)
{
    if (sender.Equals(menuItemBlue)) {
    
        // Set the checkmark for the menuItemBlue menu item.
        menuItemBlue.set_Checked(true);

        // Uncheck the menuItemRed and menuItemGreen menu items.
        menuItemRed.set_Checked(false);
        menuItemGreen.set_Checked(false);

        // Set the color of the text in the TextBox control to Blue.
        textBox1.set_ForeColor(Color.get_Blue());
    }
    else {
            if (sender.Equals(menuItemRed)) {
        
                // Set the checkmark for the menuItemRed menu item.
                menuItemRed.set_Checked(true);

                // Uncheck the menuItemBlue and menuItemGreen menu items.
                menuItemBlue.set_Checked(false);
                menuItemGreen.set_Checked(false);

                // Set the color of the text in the TextBox control to Red.
                textBox1.set_ForeColor(Color.get_Red());
            }
            else {            
                // Set the checkmark for the menuItemGreen menu item.
                menuItemGreen.set_Checked(true);

                // Uncheck the menuItemRed and menuItemGreen menu items.
                menuItemBlue.set_Checked(false);
                menuItemRed.set_Checked(false);

                // Set the color of the text in the TextBox
                // control to Blue.
                textBox1.set_ForeColor(Color.get_Green());
            }
    }
} //MyMenuClick 

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.