Initializes a new instance of the DataGrid class.
[Visual Basic] Public Sub New() [C#] public DataGrid(); [C++] public: DataGrid(); [JScript] public function DataGrid();
To populate a newly created DataGrid control, set the DataSource property to a valid source, such as a DataView, DataSet, or DataSetView.
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
DataGrid Class | DataGrid Members | System.WinForms Namespace | ColumnsCollection | DataColumn | DataMember | DataView | DataTable | GridColumnsCollection