Represents a collection of System.Windows.Forms.DataGridTableStyle objects in the System.Windows.Forms.DataGrid control.
See Also: GridTableStylesCollection Members
The System.Windows.Forms.GridTableStylesCollection contains System.Windows.Forms.DataGridTableStyle objects that allows the System.Windows.Forms.DataGrid control to display a customized grid style for each System.Data.DataTable in a System.Data.DataSet.
On the System.Windows.Forms.DataGrid control, the DataGrid.TableStyles property returns the System.Windows.Forms.GridTableStylesCollection.
By default, the System.Windows.Forms.GridTableStylesCollection does not contain any System.Windows.Forms.DataGridTableStyle objects. Instead, the System.Windows.Forms.DataGrid displays each table using default settings for color, width, and formatting. All columns of each table are displayed. When a System.Windows.Forms.DataGridTableStyle is added to the collection, the System.Windows.Forms.DataGrid uses the DataGridTableStyle.MappingName to determine which object supplies the data for the grid. For example, if the data source is a System.Data.DataSet that contains three System.Data.DataTable objects, the DataGridTableStyle.MappingName must match the System.Data.DataTable.TableName of one of the objects. If the DataGridTableStyle.MappingName does not match any of the System.Data.DataTable.TableName values, the default settings will be used to display data for each table, and the System.Windows.Forms.DataGridTableStyle settings will be ignored.
Always create System.Windows.Forms.DataGridColumnStyle objects and add them to the System.Windows.Forms.GridColumnStylesCollection before adding System.Windows.Forms.DataGridTableStyle objects to the System.Windows.Forms.GridTableStylesCollection. When you add an empty System.Windows.Forms.DataGridTableStyle with a valid DataGridTableStyle.MappingName value to the collection, System.Windows.Forms.DataGridColumnStyle objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new System.Windows.Forms.DataGridColumnStyle objects with duplicate DataGridTableStyle.MappingName values to the System.Windows.Forms.GridColumnStylesCollection. Alternatively, clear the System.Windows.Forms.GridColumnStylesCollection using the GridColumnStylesCollection.Clear method.