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

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

DataGridTableStyle.ForeColor プロパティ

グリッド テーブル前景色を取得または設定します

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

Dim instance As DataGridTableStyle
Dim value As Color

value = instance.ForeColor

instance.ForeColor = value
public Color ForeColor { get; set;
 }
/** @property */
public Color get_ForeColor ()

/** @property */
public void set_ForeColor (Color value)

プロパティ
グリッド テーブル前景色を表す Color

使用例使用例
Private Sub Create_Table()
    ' Create a DataSet.
    myDataSet = New DataSet("myDataSet")
    ' Create DataTable.
    Dim myCustomerTable As New
 DataTable("Customers")
    ' Create two columns, and add to the table.
    Dim CustID As New DataColumn("CustID",
 GetType(Integer))
    Dim CustName As New
 DataColumn("CustName")
    myCustomerTable.Columns.Add(CustID)
    myCustomerTable.Columns.Add(CustName)
    Dim newRow1 As DataRow
    ' Create three customers in the Customers Table.
    Dim i As Integer
    For i = 1 To 2
        newRow1 = myCustomerTable.NewRow()
        newRow1("custID") = i
        ' Add row to the Customers table.
        myCustomerTable.Rows.Add(newRow1)
    Next i
    ' Give each customer a distinct name.
    myCustomerTable.Rows(0)("custName") = "Alpha"
    myCustomerTable.Rows(1)("custName") = "Beta"
    ' Add table to DataSet.
    myDataSet.Tables.Add(myCustomerTable)
    dataGrid1.SetDataBinding(myDataSet, "Customers")
    myTableStyle = New DataGridTableStyle()
    myTableStyle.MappingName = "Customers"
    myTableStyle.ForeColor = Color.DarkMagenta
    dataGrid1.TableStyles.Add(myTableStyle)
End Sub 'Create_Table

' Set table's forecolor.
Private Sub OnForeColor_Click(ByVal
 sender As Object, ByVal
 e As System.EventArgs) Handles button2.Click
    dataGrid1.TableStyles.Clear()
    Select Case myComboBox.SelectedItem.ToString()
        Case "Green"
            myTableStyle.ForeColor = Color.Green
        Case "Red"
            myTableStyle.ForeColor = Color.Red
        Case "Violet"
            myTableStyle.ForeColor = Color.Violet
    End Select
    dataGrid1.TableStyles.Add(myTableStyle)
End Sub 'OnForeColor_Click
private void Create_Table()
{
   // Create a DataSet.
   myDataSet = new DataSet("myDataSet");
   // Create DataTable.
   DataTable myCustomerTable = new DataTable("Customers");
   // Create two columns, and add to the table.
   DataColumn CustID = new DataColumn("CustID", typeof(int));
   DataColumn CustName = new DataColumn("CustName");
   myCustomerTable.Columns.Add(CustID);
   myCustomerTable.Columns.Add(CustName);
   DataRow newRow1;
   // Create three customers in the Customers Table.
   for(int i = 1; i < 3; i++)
   {
      newRow1 = myCustomerTable.NewRow();
      newRow1["custID"] = i;
      // Add row to the Customers table.
      myCustomerTable.Rows.Add(newRow1);
   }
   // Give each customer a distinct name.
   myCustomerTable.Rows[0]["custName"] = "Alpha";
   myCustomerTable.Rows[1]["custName"] = "Beta";
   // Add table to DataSet.
   myDataSet.Tables.Add(myCustomerTable);
   dataGrid1.SetDataBinding(myDataSet,"Customers");
   myTableStyle = new DataGridTableStyle();
   myTableStyle.MappingName = "Customers";
   myTableStyle.ForeColor  = Color.DarkMagenta;
   dataGrid1.TableStyles.Add(myTableStyle);
}

// Set table's forecolor.
private void OnForeColor_Click(object sender,
 System.EventArgs e)
{
   dataGrid1.TableStyles.Clear();
   switch(myComboBox.SelectedItem.ToString())
   {
      case "Green":
         myTableStyle.ForeColor = Color.Green;
         break;
      case "Red":
         myTableStyle.ForeColor = Color.Red;
         break;
      case "Violet":
         myTableStyle.ForeColor = Color.Violet;
         break;
   }
   dataGrid1.TableStyles.Add(myTableStyle);
}
private:
   void Create_Table()
   {
      // Create a DataSet.
      myDataSet = gcnew DataSet( "myDataSet" );

      // Create DataTable.
      DataTable^ myCustomerTable = gcnew DataTable( "Customers" );

      // Create two columns, and add to the table.
      DataColumn^ CustID = gcnew DataColumn( "CustID",int::typeid
 );
      DataColumn^ CustName = gcnew DataColumn( "CustName" );
      myCustomerTable->Columns->Add( CustID );
      myCustomerTable->Columns->Add( CustName );
      DataRow^ newRow1;

      // Create three customers in the Customers Table.
      for ( int i = 1; i < 3; i++ )
      {
         newRow1 = myCustomerTable->NewRow();
         newRow1[ "custID" ] = i;

         // Add row to the Customers table.
         myCustomerTable->Rows->Add( newRow1 );
      }
      myCustomerTable->Rows[ 0 ][ "custName" ] = "Alpha";
      myCustomerTable->Rows[ 1 ][ "custName" ] = "Beta";

      // Add table to DataSet.
      myDataSet->Tables->Add( myCustomerTable );
      dataGrid1->SetDataBinding( myDataSet, "Customers" );
      myTableStyle = gcnew DataGridTableStyle;
      myTableStyle->MappingName = "Customers";
      myTableStyle->ForeColor = Color::DarkMagenta;
      dataGrid1->TableStyles->Add( myTableStyle );
   }

   // Set table's forecolor.
   void OnForeColor_Click( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      dataGrid1->TableStyles->Clear();
      String^ str = dynamic_cast<String^>(myComboBox->SelectedItem);
      if ( str->Equals( "Green" ) )
               myTableStyle->ForeColor = Color::Green;
      else
      if ( str->Equals( "Red" ) )
               myTableStyle->ForeColor = Color::Red;
      else
      if ( str->Equals( "Violet" ) )
               myTableStyle->ForeColor = Color::Violet;

      dataGrid1->TableStyles->Add( myTableStyle );
   }
private void Create_Table()
{
    // Create a DataSet.
    myDataSet = new DataSet("myDataSet");

    // Create DataTable.
    DataTable myCustomerTable = new DataTable("Customers");

    // Create two columns, and add to the table.
    DataColumn custID = new DataColumn("CustID", int.class.ToType());
    DataColumn custName = new DataColumn("CustName");

    myCustomerTable.get_Columns().Add(custID);
    myCustomerTable.get_Columns().Add(custName);

    DataRow newRow1;

    // Create three customers in the Customers Table.
    for (int i = 1; i < 3; i++) {
        newRow1 = myCustomerTable.NewRow();
        newRow1.set_Item("CustID", (Int32)i);

        // Add row to the Customers table.
        myCustomerTable.get_Rows().Add(newRow1);
    }

    // Give each customer a distinct name.
    myCustomerTable.get_Rows().get_Item(0).set_Item("custName", "Alpha");
    myCustomerTable.get_Rows().get_Item(1).set_Item("custName", "Beta");

    // Add table to DataSet.
    myDataSet.get_Tables().Add(myCustomerTable);
    dataGrid1.SetDataBinding(myDataSet, "Customers");
    myTableStyle = new DataGridTableStyle();
    myTableStyle.set_MappingName("Customers");
    myTableStyle.set_ForeColor(Color.get_DarkMagenta());
    dataGrid1.get_TableStyles().Add(myTableStyle);
} //Create_Table

// Set table's forecolor.
private void OnForeColor_Click(Object sender,
 System.EventArgs e)
{
    dataGrid1.get_TableStyles().Clear();
    if (myComboBox.get_SelectedItem().ToString().Equals("Green"))
 {
        myTableStyle.set_ForeColor(Color.get_Green());
    }
    else if (myComboBox.get_SelectedItem().ToString().Equals("Red"))
 {
        myTableStyle.set_ForeColor(Color.get_Red());
    }
    else if (myComboBox.get_SelectedItem().ToString().Equals("Violet"))
 {
        myTableStyle.set_ForeColor(Color.get_Violet());
    }
    dataGrid1.get_TableStyles().Add(myTableStyle);
} //OnForeColor_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS