DataGrid.BackgroundColorChanged イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGrid.BackgroundColorChanged イベントの意味・解説 

DataGrid.BackgroundColorChanged イベント

BackgroundColor が変更され場合発生します

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

Public Event BackgroundColorChanged As
 EventHandler
Dim instance As DataGrid
Dim handler As EventHandler

AddHandler instance.BackgroundColorChanged, handler
public event EventHandler BackgroundColorChanged
/** @event */
public void add_BackgroundColorChanged (EventHandler
 value)

/** @event */
public void remove_BackgroundColorChanged (EventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

BackgroundColor プロパティ値を黄色から赤に変更しBackgroundColorChanged イベント発生させるコード例次に示します

' Create an instance of the 'BackgroundColorChanged' EventHandler.
Private Sub CallBackgroundColorChanged()
   AddHandler myDataGrid.BackgroundColorChanged, AddressOf
 Grid_ColChange
End Sub 'CallBackgroundColorChanged


' Set the 'BackgroundColor' property on click of button.
 Private Sub myButton_Click(ByVal
 sender As Object, ByVal
 e As EventArgs)
     If op_Equality(myDataGrid.BackgroundColor, Color.Yellow)
 Then
         myDataGrid.BackgroundColor = Color.Red
     Else
         myDataGrid.BackgroundColor = Color.Yellow
     End If
 End Sub 'myButton_Click


' Raise the event when 'Background' color of DataGrid changes.
 Private Sub Grid_ColChange(ByVal
 sender As Object, ByVal
 e As EventArgs)
     ' String variable used to show message.
     Dim myString As String
 = "BackgroundColorChanged event raised, changed to "
     ' Get the background color of DataGrid.
     Dim myColor As Color = myDataGrid.BackgroundColor
     myString += myColor.ToString()
     ' Show information about background color setting.
     MessageBox.Show(myString, "Background color information")
 End Sub 'Grid_ColChange
// Create an instance of the 'BackgroundColorChanged' EventHandler.
private void CallBackgroundColorChanged()
{
   myDataGrid.BackgroundColorChanged += new EventHandler(Grid_ColChange);
}

// Set the 'BackgroundColor' property on click of button.
private void myButton_Click(object sender,
 EventArgs e)
{
   if (myDataGrid.BackgroundColor == Color.Yellow)
   {
      myDataGrid.BackgroundColor = Color.Red;
   }
   else
   {
      myDataGrid.BackgroundColor = Color.Yellow;
   }
}

// Raise the event when 'Background' color of DataGrid changes.
private void Grid_ColChange(object sender,
 EventArgs e)
{
   // String variable used to show message.
   string myString = "BackgroundColorChanged event raised,
 changed to ";
   // Get the background color of DataGrid.
   Color myColor = myDataGrid.BackgroundColor;
   myString += myColor.ToString();
   // Show information about background color setting.
   MessageBox.Show(myString, "Background color information");
}
   // Create an instance of the 'BackgroundColorChanged' EventHandler.
private:
   void CallBackgroundColorChanged()
   {
      myDataGrid->BackgroundColorChanged += gcnew EventHandler( this,
 &MyDataGrid::Grid_ColChange );
   }

   // Set the 'BackgroundColor' property on click of button.
   void myButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( myDataGrid->BackgroundColor == Color::Yellow )
      {
         myDataGrid->BackgroundColor = Color::Red;
      }
      else
      {
         myDataGrid->BackgroundColor = Color::Yellow;
      }
   }

   // Raise the event when 'Background' color of DataGrid changes.
   void Grid_ColChange( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      // String variable used to show message.
      String^ myString = "BackgroundColorChanged event raised, changed to ";

      // Get the background color of DataGrid.
      Color myColor = myDataGrid->BackgroundColor;
      myString = String::Concat( myString, myColor );

      // Show information about background color setting.
      MessageBox::Show( myString, "Background color information" );
   }
// Create an instance of the 'BackgroundColorChanged' EventHandler.
private void CallBackgroundColorChanged()
{
    myDataGrid.add_BackgroundColorChanged(new EventHandler(GridColChange));
} //CallBackgroundColorChanged

// Set the 'BackgroundColor' property on click of button.
protected void myButton_Click(Object sender,
 EventArgs e)
{
    if (myDataGrid.get_BackgroundColor().Equals(Color.get_Yellow()))
 {
        myDataGrid.set_BackgroundColor(Color.get_Red());
    }
    else {
        myDataGrid.set_BackgroundColor(Color.get_Yellow());
    }
} //myButton_Click

// Raise the event when 'Background' color of DataGrid changes.
protected void GridColChange(Object sender,
 EventArgs e)
{
    // String variable used to show message.
    String myString = "BackgroundColorChanged event raised, changed to ";

    // Get the background color of DataGrid.
    Color myColor = myDataGrid.get_BackgroundColor();

    myString += myColor.ToString();

    // Show information about background color setting.
    MessageBox.Show(myString, "Background color information");
} //GridColChange
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

DataGrid.BackgroundColorChanged イベントのお隣キーワード
検索ランキング

   

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



DataGrid.BackgroundColorChanged イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS