DataGrid 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 DataGrid 类的新实例。
public:
DataGrid();
public DataGrid ();
Public Sub New ()
示例
下面的代码示例创建一个新 System.Windows.Forms.DataGrid 代码,并使用 SetDataBinding 该方法设置 DataSource 和 DataMember 属性。
' This object variable must go in the Declarations section:
Private DataGrid1 As DataGrid
Private Sub CreateDataGrid()
' Initialize a new DataGrid control.
me.Datagrid1 = New DataGrid
Dim myDataSet As DataSet = New DataSet("myDataSet")
Dim myDataTable As DataTable = New DataTable("Customers")
myDataSet.Tables.Add(myDataTable)
' Insert code to populate the DataTable with rows.
' Set the DataSource and DataMember of the DataGrid control.
DataGrid1.SetDataBinding(myDataSet, "Customers")
End Sub
注解
若要填充新创建的 System.Windows.Forms.DataGrid 控件,请将 DataSource 属性设置为有效的源,例如 DataView, DataSet或 DataViewManager。