GridTableStylesCollectionとは? わかりやすく解説

GridTableStylesCollection イベント


パブリック イベントパブリック イベント

  名前 説明
パブリック イベント CollectionChanged コレクション変更され場合発生します
参照参照

関連項目

GridTableStylesCollection クラス
System.Windows.Forms 名前空間
DataGrid クラス
DataGridTableStyle.GridColumnStyles プロパティ

GridTableStylesCollection クラス

DataGrid コントロール内の DataGridTableStyle オブジェクトコレクション表します

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

Public Class GridTableStylesCollection
    Inherits BaseCollection
    Implements IList, ICollection, IEnumerable
Dim instance As GridTableStylesCollection
public class GridTableStylesCollection : BaseCollection,
 IList, ICollection, IEnumerable
public ref class GridTableStylesCollection
 : public BaseCollection, IList, ICollection, IEnumerable
public class GridTableStylesCollection extends
 BaseCollection implements IList, ICollection, 
    IEnumerable
public class GridTableStylesCollection extends
 BaseCollection implements IList, ICollection, 
    IEnumerable
解説解説

GridTableStylesCollectionDataGridTableStyle オブジェクト格納しますDataGrid コントロールは、このオブジェクト使用して DataSet 内の各 DataTable にカスタマイズされたグリッド スタイル表示できます

DataGrid コントロールでは、TableStyles プロパティGridTableStylesCollection返します

既定では、GridTableStylesCollection には DataGridTableStyle オブジェクト格納されていません。代わりにDataGrid は、色、幅、および書式指定について既定設定値使用してテーブル表示しますまた、テーブルすべての列が表示されます。DataGridTableStyleコレクション追加されると、DataGrid は MappingName を使用してグリッドデータ提供するオブジェクト決定します。たとえば、データ ソース3 つの DataTable オブジェクト格納する DataSet場合MappingName は、それらのオブジェクトいずれかの TableName と一致する必要がありますMappingNameいずれの TableName 値とも一致しない場合は、既定設定値使用してテーブルデータ表示されDataGridTableStyle設定値無視されます。

注意に関するメモ注意

必ず DataGridColumnStyle オブジェクト作成して GridColumnStylesCollection に追加してから、DataGridTableStyle オブジェクトGridTableStylesCollection追加します有効な MappingName 値を持つ空の DataGridTableStyleコレクション追加すると、自動的に DataGridColumnStyle オブジェクト生成されます。そのため、MappingName 値が重複する新しDataGridColumnStyle オブジェクトGridColumnStylesCollection追加しようとすると、例外スローさます。または、Clear メソッド使用してGridColumnStylesCollection を空にします。

使用例使用例

2 つDataGridTableStyle オブジェクト作成し、各オブジェクトDataGrid コントロールTableStyles プロパティから返されGridTableStylesCollection追加するコード例次に示します

Private Sub AddCustomDataTableStyle()
   Dim ts1 As New DataGridTableStyle()
   ts1.MappingName = "Customers"
   ' Set other properties.
   ts1.AlternatingBackColor = Color.LightGray
   ' Add a GridColumnStyle and set its MappingName 
   ' to the name of a DataColumn in the DataTable. 
   ' Set the HeaderText and Width properties. 
     
   Dim boolCol As New DataGridBoolColumn()
   boolCol.MappingName = "Current"
   boolCol.HeaderText = "IsCurrent Customer"
   boolCol.Width = 150
   ts1.GridColumnStyles.Add(boolCol)
     
   ' Add a second column style.
   Dim TextCol As New DataGridTextBoxColumn()
   TextCol.MappingName = "custName"
   TextCol.HeaderText = "Customer Name"
   TextCol.Width = 250
   ts1.GridColumnStyles.Add(TextCol)
     
   ' Create the second table style with columns.
   Dim ts2 As New DataGridTableStyle()
   ts2.MappingName = "Orders"
     
   ' Set other properties.
   ts2.AlternatingBackColor = Color.LightBlue
     
   ' Create new ColumnStyle objects.
   Dim cOrderDate As New
 DataGridTextBoxColumn()
   cOrderDate.MappingName = "OrderDate"
   cOrderDate.HeaderText = "Order Date"
   cOrderDate.Width = 100
   ts2.GridColumnStyles.Add(cOrderDate)

   ' Use a PropertyDescriptor to create a formatted
   ' column. First get the PropertyDescriptorCollection
   ' for the data source and data member. 
   Dim pcol As System.ComponentModel.PropertyDescriptorCollection
 = _
   Me.BindingContext(myDataSet, "Customers.custToOrders").
 _
   GetItemProperties()

   ' Create a formatted column using a PropertyDescriptor.
   ' The formatting character "c" specifies a currency format.
 */     
     
   Dim csOrderAmount As _
   New DataGridTextBoxColumn(pcol("OrderAmount"),
 "c", True)
   csOrderAmount.MappingName = "OrderAmount"
   csOrderAmount.HeaderText = "Total"
   csOrderAmount.Width = 100
   ts2.GridColumnStyles.Add(csOrderAmount)
     
   ' Add the DataGridTableStyle instances to 
   ' the GridTableStylesCollection. 
   myDataGrid.TableStyles.Add(ts1)
   myDataGrid.TableStyles.Add(ts2)
End Sub 'AddCustomDataTableStyle
private void AddCustomDataTableStyle(){
   DataGridTableStyle ts1 = new DataGridTableStyle();
   ts1.MappingName = "Customers";
   // Set other properties.
   ts1.AlternatingBackColor = Color.LightGray;

   /* Add a GridColumnStyle and set its MappingName 
   to the name of a DataColumn in the DataTable. 
   Set the HeaderText and Width properties. */
   
   DataGridColumnStyle boolCol = new DataGridBoolColumn();
   boolCol.MappingName = "Current";
   boolCol.HeaderText = "IsCurrent Customer";
   boolCol.Width = 150;
   ts1.GridColumnStyles.Add(boolCol);
   
   // Add a second column style.
   DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
   TextCol.MappingName = "custName";
   TextCol.HeaderText = "Customer Name";
   TextCol.Width = 250;
   ts1.GridColumnStyles.Add(TextCol);

   // Create the second table style with columns.
   DataGridTableStyle ts2 = new DataGridTableStyle();
   ts2.MappingName = "Orders";

   // Set other properties.
   ts2.AlternatingBackColor = Color.LightBlue;
   
   // Create new ColumnStyle objects.
   DataGridColumnStyle cOrderDate = 
   new DataGridTextBoxColumn();
   cOrderDate.MappingName = "OrderDate";
   cOrderDate.HeaderText = "Order Date";
   cOrderDate.Width = 100;
   ts2.GridColumnStyles.Add(cOrderDate);

   /*Use a PropertyDescriptor to create a formatted
   column. First get the PropertyDescriptorCollection
   for the data source and data member. */
   System.ComponentModel.PropertyDescriptorCollection pcol = 
      this.BindingContext[myDataSet, "Customers.custToOrders"]
      .GetItemProperties();
 
   /* Create a formatted column using a PropertyDescriptor.
   The formatting character "c" specifies a currency format. */     
   DataGridColumnStyle csOrderAmount = 
   new DataGridTextBoxColumn(pcol["OrderAmount"], "c",
 true);
   csOrderAmount.MappingName = "OrderAmount";
   csOrderAmount.HeaderText = "Total";
   csOrderAmount.Width = 100;
   ts2.GridColumnStyles.Add(csOrderAmount);

   /* Add the DataGridTableStyle instances to 
   the GridTableStylesCollection. */
   myDataGrid.TableStyles.Add(ts1);
   myDataGrid.TableStyles.Add(ts2);
}
void AddCustomDataTableStyle()
{
   DataGridTableStyle^ ts1 = gcnew DataGridTableStyle;
   ts1->MappingName = "Customers";
   
   // Set other properties.
   ts1->AlternatingBackColor = Color::LightGray;
   
   /* Add a GridColumnStyle and set its MappingName
     to the name of a DataColumn in the DataTable.
     Set the HeaderText and Width properties. */
   DataGridColumnStyle^ boolCol = gcnew DataGridBoolColumn;
   boolCol->MappingName = "Current";
   boolCol->HeaderText = "IsCurrent Customer";
   boolCol->Width = 150;
   ts1->GridColumnStyles->Add( boolCol );
   
   // Add a second column style.
   DataGridColumnStyle^ TextCol = gcnew DataGridTextBoxColumn;
   TextCol->MappingName = "custName";
   TextCol->HeaderText = "Customer Name";
   TextCol->Width = 250;
   ts1->GridColumnStyles->Add( TextCol );
   
   // Create the second table style with columns.
   DataGridTableStyle^ ts2 = gcnew DataGridTableStyle;
   ts2->MappingName = "Orders";
   
   // Set other properties.
   ts2->AlternatingBackColor = Color::LightBlue;
   
   // Create new ColumnStyle objects.
   DataGridColumnStyle^ cOrderDate = gcnew DataGridTextBoxColumn;
   cOrderDate->MappingName = "OrderDate";
   cOrderDate->HeaderText = "Order Date";
   cOrderDate->Width = 100;
   ts2->GridColumnStyles->Add( cOrderDate );
   
   /*Use a PropertyDescriptor to create a formatted
     column. First get the PropertyDescriptorCollection
     for the data source and data member. */
   System::ComponentModel::PropertyDescriptorCollection^ pcol = this->
       BindingContext[myDataSet, "Customers::custToOrders"]->
       GetItemProperties();
   
   /* Create a formatted column using a PropertyDescriptor.
     The formatting character S"c" specifies a currency format. */
   DataGridColumnStyle^ csOrderAmount =
      gcnew DataGridTextBoxColumn( pcol[ "OrderAmount" ],"c",true
 );
   csOrderAmount->MappingName = "OrderAmount";
   csOrderAmount->HeaderText = "Total";
   csOrderAmount->Width = 100;
   ts2->GridColumnStyles->Add( csOrderAmount );
   
   /* Add the DataGridTableStyle instances to
     the GridTableStylesCollection. */
   myDataGrid->TableStyles->Add( ts1 );
   myDataGrid->TableStyles->Add( ts2 );
}
private void AddCustomDataTableStyle()
{
    DataGridTableStyle ts1 = new DataGridTableStyle();
    ts1.set_MappingName("Customers");

    // Set other properties.
    ts1.set_AlternatingBackColor(Color.get_LightGray());

    /*  Add a GridColumnStyle and set its MappingName to the name
 of a 
        DataColumn in the DataTable. Set the HeaderText and Width
 
        properties.
     */
    DataGridColumnStyle boolCol = new DataGridBoolColumn();

    boolCol.set_MappingName("Current");
    boolCol.set_HeaderText("IsCurrent Customer");
    boolCol.set_Width(150);
    ts1.get_GridColumnStyles().Add(boolCol);

    // Add a second column style.
    DataGridColumnStyle TextCol = new DataGridTextBoxColumn();

    TextCol.set_MappingName("custName");
    TextCol.set_HeaderText("Customer Name");
    TextCol.set_Width(250);
    ts1.get_GridColumnStyles().Add(TextCol);

    // Create the second table style with columns.
    DataGridTableStyle ts2 = new DataGridTableStyle();
    ts2.set_MappingName("Orders");

    // Set other properties.
    ts2.set_AlternatingBackColor(Color.get_LightBlue());

    // Create new ColumnStyle objects.
    DataGridColumnStyle cOrderDate = new DataGridTextBoxColumn();

    cOrderDate.set_MappingName("OrderDate");
    cOrderDate.set_HeaderText("Order Date");
    cOrderDate.set_Width(100);
    ts2.get_GridColumnStyles().Add(cOrderDate);

    /*  Use a PropertyDescriptor to create a formatted column. First get
 the 
        the PropertyDescriptorCollection for the data source and
 data member. 
    */
    PropertyDescriptorCollection pcol = this.get_BindingContext().
        get_Item(myDataSet, "Customers.custToOrders").GetItemProperties();

    /*  Create a formatted column using a PropertyDescriptor.
        The formatting character "c" specifies a currency format.
     */
    DataGridColumnStyle csOrderAmount = new DataGridTextBoxColumn(pcol.
        get_Item("OrderAmount"), "c", true);

    csOrderAmount.set_MappingName("OrderAmount");
    csOrderAmount.set_HeaderText("Total");
    csOrderAmount.set_Width(100);
    ts2.get_GridColumnStyles().Add(csOrderAmount);

    /*  Add the DataGridTableStyle instances to 
        the GridTableStylesCollection. 
     */
    myDataGrid.get_TableStyles().Add(ts1);
    myDataGrid.get_TableStyles().Add(ts2);
} //AddCustomDataTableStyle
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.Windows.Forms.BaseCollection
      System.Windows.Forms.GridTableStylesCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridTableStylesCollection メンバ
System.Windows.Forms 名前空間
DataGrid クラス
DataGridTableStyle.GridColumnStyles プロパティ

GridTableStylesCollection プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count  コレクション内の要素合計数を取得します。 ( BaseCollection から継承されます。)
パブリック プロパティ IsReadOnly  コレクション読み取り専用かどうかを示す値を取得します。 ( BaseCollection から継承されます。)
パブリック プロパティ IsSynchronized  ICollection へのアクセス同期がとられているかどうかを示す値を取得します。 ( BaseCollection から継承されます。)
パブリック プロパティ Item オーバーロードされます指定した DataGridTableStyle を取得します
パブリック プロパティ SyncRoot  BaseCollection へのアクセス同期するために使用できるオブジェクト取得します。 ( BaseCollection から継承されます。)
プロテクト プロパティプロテクト プロパティ
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IList.Item 指定したインデックスにある要素取得または設定します
参照参照

関連項目

GridTableStylesCollection クラス
System.Windows.Forms 名前空間
DataGrid クラス
DataGridTableStyle.GridColumnStyles プロパティ

GridTableStylesCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add DataGridTableStyle をコレクション追加します
パブリック メソッド AddRange テーブル スタイル配列コレクション追加します
パブリック メソッド Clear コレクションを空にします。
パブリック メソッド Contains オーバーロードされます指定した DataGridTableStyle が GridTableStylesCollection に格納されているかどうかを示す値を取得します
パブリック メソッド CopyTo  指定したコピー先の Array インデックス開始位置として、現在の 1 次元 Arrayすべての要素指定した 1 次元 Arrayコピーします。 ( BaseCollection から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator  コレクションメンバ反復処理できるオブジェクト取得します。 ( BaseCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定した DataGridTableStyle削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある DataGridTableStyle削除します
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクション互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション列挙子を返します
インターフェイスの明示的な実装 System.Collections.IList.Add DataGridTableStyleコレクション追加します
インターフェイスの明示的な実装 System.Collections.IList.Clear コレクションを空にします。
インターフェイスの明示的な実装 System.Collections.IList.Contains ある要素コレクション内に存在するかどうか判断します
インターフェイスの明示的な実装 System.Collections.IList.IndexOf コレクション内にある指定したオブジェクトのうち、最初に出現する値の、0 から始まるインデックス番号返します
インターフェイスの明示的な実装 System.Collections.IList.Insert Insert メソッド実装ます。常に NotSupportedException をスローます。
インターフェイスの明示的な実装 System.Collections.IList.Remove 指定した DataGridTableStyle削除します
インターフェイスの明示的な実装 System.Collections.IList.RemoveAt 指定したインデックスの DataGridColumnStyle をコレクションから削除します
参照参照

関連項目

GridTableStylesCollection クラス
System.Windows.Forms 名前空間
DataGrid クラス
DataGridTableStyle.GridColumnStyles プロパティ

GridTableStylesCollection メンバ

DataGrid コントロール内の DataGridTableStyle オブジェクトコレクション表します

GridTableStylesCollection データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count  コレクション内の要素合計数を取得します。(BaseCollection から継承されます。)
パブリック プロパティ IsReadOnly  コレクション読み取り専用かどうかを示す値を取得します。(BaseCollection から継承されます。)
パブリック プロパティ IsSynchronized  ICollection へのアクセス同期がとられているかどうかを示す値を取得します。(BaseCollection から継承されます。)
パブリック プロパティ Item オーバーロードされます指定した DataGridTableStyle取得します
パブリック プロパティ SyncRoot  BaseCollection へのアクセス同期するために使用できるオブジェクト取得します。(BaseCollection から継承されます。)
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add DataGridTableStyleコレクション追加します
パブリック メソッド AddRange テーブル スタイル配列コレクション追加します
パブリック メソッド Clear コレクションを空にします。
パブリック メソッド Contains オーバーロードされます指定した DataGridTableStyle が GridTableStylesCollection に格納されているかどうかを示す値を取得します
パブリック メソッド CopyTo  指定したコピー先の Array インデックス開始位置として、現在の 1 次元 Arrayすべての要素指定した 1 次元 Arrayコピーします。 (BaseCollection から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator  コレクションメンバ反復処理できるオブジェクト取得します。 (BaseCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定した DataGridTableStyle削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある DataGridTableStyle削除します
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント CollectionChanged コレクション変更され場合発生します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクション互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション列挙子を返します
インターフェイスの明示的な実装 System.Collections.IList.Add DataGridTableStyleコレクション追加します
インターフェイスの明示的な実装 System.Collections.IList.Clear コレクションを空にします。
インターフェイスの明示的な実装 System.Collections.IList.Contains ある要素コレクション内に存在するかどうか判断します
インターフェイスの明示的な実装 System.Collections.IList.IndexOf コレクション内にある指定したオブジェクトのうち、最初に出現する値の、0 から始まるインデックス番号返します
インターフェイスの明示的な実装 System.Collections.IList.Insert Insert メソッド実装ます。常に NotSupportedException をスローます。
インターフェイスの明示的な実装 System.Collections.IList.Remove 指定した DataGridTableStyle削除します
インターフェイスの明示的な実装 System.Collections.IList.RemoveAt 指定したインデックスの DataGridColumnStyle をコレクションから削除します
インターフェイスの明示的な実装 System.Collections.IList.Item 指定したインデックスにある要素取得または設定します
参照参照

関連項目

GridTableStylesCollection クラス
System.Windows.Forms 名前空間
DataGrid クラス
DataGridTableStyle.GridColumnStyles プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からGridTableStylesCollectionを検索した結果を表示しています。
Weblioに収録されているすべての辞書からGridTableStylesCollectionを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からGridTableStylesCollection を検索

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

辞書ショートカット

すべての辞書の索引

「GridTableStylesCollection」の関連用語

GridTableStylesCollectionのお隣キーワード
検索ランキング

   

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



GridTableStylesCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS