DataGridTableStyle.GridColumnStyles DataGridTableStyle.GridColumnStyles DataGridTableStyle.GridColumnStyles DataGridTableStyle.GridColumnStyles Property


获取所绘制的该表中列的集合。Gets the collection of columns drawn for this table.

 virtual property System::Windows::Forms::GridColumnStylesCollection ^ GridColumnStyles { System::Windows::Forms::GridColumnStylesCollection ^ get(); };
public virtual System.Windows.Forms.GridColumnStylesCollection GridColumnStyles { get; }
member this.GridColumnStyles : System.Windows.Forms.GridColumnStylesCollection
Public Overridable ReadOnly Property GridColumnStyles As GridColumnStylesCollection



下面的代码示例获取 @no__t 的 @no__t 0,并打印每个对象的标头。The following code example gets the GridColumnStylesCollection of a DataGridTableStyle and prints each object's header.

   void WriteMappingNames()
      for each ( DataGridTableStyle^ dgt in myDataGrid->TableStyles )
         Console::WriteLine( dgt->MappingName );
         for each ( DataGridColumnStyle^ dgc in dgt->GridColumnStyles )
            Console::WriteLine( dgc->MappingName );
private void WriteMappingNames(){
    foreach(DataGridTableStyle dgt in myDataGrid.TableStyles)
        foreach(DataGridColumnStyle dgc in dgt.GridColumnStyles)
Private Sub WriteMappingNames()
    Dim dgt As DataGridTableStyle
    For Each dgt In  myDataGrid.TableStyles
        Dim dgc As DataGridColumnStyle
        For Each dgc In  dgt.GridColumnStyles
        Next dgc
    Next dgt
End Sub


通过 @no__t 属性返回的 @no__t 0,您可以创建一组自定义的列样式。The GridColumnStylesCollection returned by the GridColumnStyles property allows you to create a customized set of column styles. 对于 @no__t 中的每个 DataTable,将 @no__t 的 @no__t 2 设置为 @no__t。For each DataColumn in a DataTable, set the MappingName of a DataGridColumnStyle to the ColumnName. 显示此 DataGridTableStyle 时将自动使用该列样式。That column style will automatically be used when this DataGridTableStyle is displayed.

如果创建的 @no__t 为-0,而不将任何 @no__t 1 对象添加到 GridColumnStylesCollection,则在将具有有效 @no__t 的 @no__t 添加到 @no__t 时,将自动创建一个 @no__t 3 个对象的集合。If you create a DataGridTableStyle without adding any DataGridColumnStyle objects to the GridColumnStylesCollection, a collection of DataGridColumnStyle objects will be created automatically when a DataGridTableStyle with a valid MappingName is added to the GridTableStylesCollection. 如果尝试将具有重复 @no__t 1 值的 @no__t 对象添加到集合中,则会引发异常。An exception will be thrown if you attempt to add DataGridColumnStyle objects with duplicate MappingName values to the collection.