The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataGridTableStyle.GridColumnStyles Property

Gets the collection of columns drawn for this table.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public virtual GridColumnStylesCollection GridColumnStyles { get; }
/** @property */
public GridColumnStylesCollection get_GridColumnStyles ()

public function get GridColumnStyles () : GridColumnStylesCollection

Not applicable.

Property Value

A GridColumnStylesCollection that contains all DataGridColumnStyle objects for the table.

The GridColumnStylesCollection returned by the GridColumnStyles property allows you to create a customized set of column styles. For each DataColumn in a DataTable, set the MappingName of a DataGridColumnStyle to the ColumnName. That column style will automatically be used when this DataGridTableStyle is displayed.

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. An exception will be thrown if you attempt to add DataGridColumnStyle objects with duplicate MappingName values to the collection.

The following code example gets the GridColumnStylesCollection of a DataGridTableStyle and prints each object's header.

private void WriteMappingNames(){
    foreach(DataGridTableStyle dgt in myDataGrid.TableStyles)
        foreach(DataGridColumnStyle dgc in dgt.GridColumnStyles)

private void WriteMappingNames()
    DataGridTableStyle dgt;
    for (int iCtr = 0; iCtr < myDataGrid.get_TableStyles().get_Count(); 
        iCtr++) {
        dgt = myDataGrid.get_TableStyles().get_Item(iCtr);
        DataGridColumnStyle dgc;
        for (int iCtr1 = 0; iCtr1 < dgt.get_GridColumnStyles().get_Count(); 
            iCtr1++) {
            dgc = dgt.get_GridColumnStyles().get_Item(iCtr1);
} //WriteMappingNames

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions