NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataGrid.GridColumns

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;

Property Value

A GridColumnsCollection that represents the collection of DataGridColumn objects.

Remarks

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.

Example [Visual Basic]

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

See Also

DataGrid Class | DataGrid Members | System.WinForms Namespace | DataColumn | GridColumnsCollection | DataGridColumn | DataTable