Gets the collection of drawn columns for the grid.
[Visual Basic] Public ReadOnly Property GridColumns As GridColumnsCollection [C#] public GridColumnsCollection GridColumns {get;} [C++] public: __property GridColumnsCollection* get_GridColumns(); [JScript] public function get GridColumns() : GridColumnsCollection;
A GridColumnsCollection that represents the collection of DataGridColumn objects.
Use the GridColumnsCollection object's Add method to add columns to the collection.
Columns are added automatically to the GridColumnsCollection, one for each DataColumn in the DataTable displayed by the DataGrid. Therefore, if you add a DataColumn to the DataTable object's ColumnsCollection, a corresponding DataGridColumn will be added to the GridColumnsCollection. However, you must invoke the PopulateColumns method to display the new column in the DataGrid control.
The following example returns the collection of grid columns, and prints each column's type.
[Visual Basic]
Private Sub PrintColTypes(ByRef myGrid As DataGrid) Dim myColumns As New GridColumnsCollection Set myColumns = DataGrid1.GridColumns Dim col As DataGridColumn For Each col in myColumns Console.WriteLine(col.ToString) Next End Sub
DataGrid Class | DataGrid Members | System.WinForms Namespace | DataColumn | GridColumnsCollection | DataGridColumn | DataTable