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 Constructor

Initializes a new instance of the DataGrid class.

[Visual Basic]
Public Sub New()
[C#]
public DataGrid();
[C++]
public: DataGrid();
[JScript]
public function DataGrid();

Remarks

To populate a newly created DataGrid control, set the DataSource property to a valid source, such as a DataView, DataSet, or DataSetView.

Example [Visual Basic]

The following example creates a new DataGrid and sets the System.WinForms.DataSource to a System.WinForms.DataView object.

[Visual Basic]

' This object variable must go in the Declarations section:
Private DataGrid1 As System.Winforms.DataGrid

Private Sub CreateDataGrid()
   ' Initialize a new DataGrid control.
   Set me.Datagrid1 = New System.Winforms.DataGrid
   ' Set the DataSource of the DataGrid control.
   Dim dv As DataView
   ' Not shown: code to populate a DataTable with rows.
   dv = New DataView(myDataTable)
   DataGrid1.DataSource = dv
   
   ' You must invoke the DataGrid control's PopulateColumns method.
   DataGrid1.PopulateColumns
End Sub

See Also

DataGrid Class | DataGrid Members | System.WinForms Namespace | ColumnsCollection | DataColumn | DataMember | DataView | DataTable | GridColumnsCollection