MenuItem.RadioCheck プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As MenuItem Dim value As Boolean value = instance.RadioCheck instance.RadioCheck = value
/** @property */ public boolean get_RadioCheck () /** @property */ public void set_RadioCheck (boolean value)
メニュー項目がチェックされた場合に、チェック マークの代わりにオプション ボタンが使用される場合は true。標準のチェック マークが表示される場合は false。既定値は false です。

チェック マークは、メニュー項目グループ内の複数の項目を同時に選択できないことを意味するとは限りません。メニュー項目のチェック マークによって、複数の項目を同時に選択できないことをユーザーに示すには、このプロパティを使用します。

Checked プロパティを使用して、アプリケーションの状態を変更するコード例を次に示します。この例では、TextBox コントロール内のテキストの色を指定するために使用される複数のメニュー項目がグループにまとめて提供されています。この例で指定されているイベント ハンドラは、3 つのメニュー項目の Click イベントによって使用されます。各メニュー項目は、menuItemRed、menuItemGreen、menuItemBlue のいずれかの色を指定します。イベント ハンドラは、クリックされたメニュー項目を判断し、選択されたそのメニュー項目にチェック マークを付け、フォーム上の TextBox コントロール textBox1 のテキストの色を変更します。また、この例では、RadioCheck プロパティを使用して、一度に 1 つしか選択できない複数のメニュー項目を示すために、オプション ボタンのチェック マークを使用する方法も示しています。この例では、このコードが記述されているフォームに System.Drawing 名前空間が追加されている必要があります。
' 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
// 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; } }
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.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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMenuItem.RadioCheck プロパティを検索する場合は、下記のリンクをクリックしてください。

- MenuItem.RadioCheck プロパティのページへのリンク