GridColumnStylesCollection Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration Public Class GridColumnStylesCollection Inherits BaseCollection Implements IList, ICollection, IEnumerable 'Usage Dim instance As GridColumnStylesCollection
public class GridColumnStylesCollection extends BaseCollection implements IList, ICollection, IEnumerable
public class GridColumnStylesCollection extends BaseCollection implements IList, ICollection, IEnumerable
On the DataGridTableStyle, you access the GridColumnStylesCollection through the GridColumnStyles property.
The GridColumnStylesCollection uses standard Add and Remove methods to manipulate the collection.
Use the Contains method to determine if a specific property value exists in the collection. Additionally, use the IndexOf method to determine the index of any DataGridColumnStyle object within the collection.
Caution |
|---|
| Always create DataGridColumnStyle objects and add them to the GridColumnStylesCollection before adding DataGridTableStyle objects to the GridTableStylesCollection. When you add an empty DataGridTableStyle with a valid MappingName value to the collection, DataGridColumnStyle objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new DataGridColumnStyle objects with duplicate MappingName values to the GridColumnStylesCollection. |
The following code example prints information about each DataGridColumnStyle in a GridColumnStylesCollection.
Private Sub PrintColumnInformation(grid as DataGrid) Console.WriteLine("Count: " & grid.TableStyles.Count) Dim myTableStyle As DataGridTableStyle Dim myColumns As GridColumnStylesCollection Dim dgCol As DataGridColumnStyle For Each myTableStyle in grid.TableStyles myColumns = myTableStyle.GridColumnStyles ' Iterate through the collection and print each ' object's type and width. For Each dgCol in myColumns Console.WriteLine(dgCol.MappingName) Console.WriteLine(dgCol.GetType.ToString()) Console.WriteLine(dgCol.Width) Next Next End Sub
private void PrintColumnInformation(DataGrid grid)
{
Console.WriteLine(("Count: " + grid.get_TableStyles().get_Count()));
GridColumnStylesCollection myColumns;
for (int iCtr = 0; iCtr < grid.get_TableStyles().get_Count();
iCtr++) {
DataGridTableStyle myTableStyle =
grid.get_TableStyles().get_Item(iCtr);
myColumns = myTableStyle.get_GridColumnStyles();
/* Iterate through the collection and print each
* object's type and width.
*/
for (int iCtr1 = 0; iCtr1 < myColumns.get_Count(); iCtr1++) {
DataGridColumnStyle dgCol = myColumns.get_Item(iCtr1);
Console.WriteLine(dgCol.get_MappingName());
Console.WriteLine(dgCol.GetType().ToString());
Console.WriteLine(dgCol.get_Width());
}
}
} //PrintColumnInformation
function PrintColumnInformation(grid: DataGrid){ Console.WriteLine("Count: " + grid.TableStyles.Count); var myColumns: GridColumnStylesCollection; for(var myTableStyle in grid.TableStyles){ myColumns = myTableStyle.GridColumnStyles; // Iterate through the collection and print each // object's type and width. for (var dgCol in myColumns){ Console.WriteLine(dgCol.MappingName); Console.WriteLine(dgCol.GetType().ToString()); Console.WriteLine(dgCol.Width); } } }
System.MarshalByRefObject
System.Windows.Forms.BaseCollection
System.Windows.Forms.GridColumnStylesCollection
Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Caution