MenuItem.RadioCheck プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MenuItem.RadioCheck プロパティの意味・解説 

MenuItem.RadioCheck プロパティ

MenuItem がチェックされている場合チェック マーク代わりにオプション ボタン表示するかどうかを示す値を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

Checked プロパティ使用してアプリケーションの状態を変更するコード例次に示します。この例では、TextBox コントロール内のテキストの色を指定するために使用される複数メニュー項目がグループまとめて提供されています。この例で指定されているイベント ハンドラは、3 つのメニュー項目の Click イベントによって使用されます。メニュー項目は、menuItemRedmenuItemGreenmenuItemBlueいずれかの色を指定しますイベント ハンドラは、クリックされたメニュー項目を判断し選択されたそのメニュー項目にチェック マーク付けフォーム上の 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 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MenuItem.RadioCheck プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MenuItem.RadioCheck プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS