MenuItem.RadioCheck Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of het MenuItemkeuzerondje , indien ingeschakeld, een keuzerondje weergeeft in plaats van een vinkje.
public:
property bool RadioCheck { bool get(); void set(bool value); };
public bool RadioCheck { get; set; }
member this.RadioCheck : bool with get, set
Public Property RadioCheck As Boolean
Waarde van eigenschap
true als een keuzerondje moet worden gebruikt in plaats van een vinkje; false als het standaard vinkje moet worden weergegeven wanneer het menu-item is ingeschakeld. De standaardwaarde is false.
Voorbeelden
In het volgende codevoorbeeld wordt de Checked eigenschap gebruikt om de status van een toepassing te wijzigen. In het voorbeeld wordt een groep menu-items opgegeven die worden gebruikt om de kleur voor de tekst in een TextBox besturingselement op te geven. In het voorbeeld wordt de opgegeven gebeurtenis-handler gebruikt door de Click gebeurtenis van de drie menu-items. Elk menu-item geeft een kleur, menuItemRed, menuItemGreenof menuItemBlue. De gebeurtenis-handler bepaalt op welk menu-item is geklikt, plaatst een vinkje op het geselecteerde menu-item en wijzigt de tekstkleur van het besturingselement van het formulier TextBox met de naam textBox1. In het voorbeeld wordt ook de RadioCheck eigenschap gebruikt om te laten zien hoe een keuzerondje wordt gebruikt om menu-items weer te geven die elkaar wederzijds uitsluiten. In dit voorbeeld moet de System.Drawing naamruimte zijn toegevoegd aan het formulier dat deze code bevat.
public:
// This method is called from the constructor of the form to set up the menu items.
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;
}
private:
// The following event handler would be connected to three menu items.
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.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 Sub 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
End Sub
' The following event handler would be connected to three menu items.
Private Sub MyMenuClick(sender As Object, e As EventArgs)
If sender Is menuItemBlue Then
' 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 Is menuItemRed Then
' 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
End If
End If
End Sub
Opmerkingen
Vinkjes impliceren niet noodzakelijkerwijs een wederzijds exclusieve status voor een groep menu-items. U kunt deze eigenschap gebruiken om de gebruiker aan te geven dat het vinkje van een menu-item wederzijds exclusief is.