次の方法で共有


DataGrid コンストラクタ

System.Windows.Forms.DataGrid クラスの新しいインスタンスを初期化します。

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

解説

新しく作成した System.Windows.Forms.DataGrid コントロールを読み込むには、 DataSource プロパティを DataViewDataSetDataViewManager などの有効なソースに設定します。

使用例

[Visual Basic] 新しい 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

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間 | DataColumnCollection | DataColumn | DataMember | DataView | DataTable | GridTableStylesCollection