DataGrid.SetDataBinding メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGrid Dim dataSource As Object Dim dataMember As String instance.SetDataBinding(dataSource, dataMember)


実行時に SetDataBinding メソッドを使用して、DataSource プロパティをリセットする必要があります。
有効なデータ ソースを設定する方法の詳細については、DataSource プロパティのトピックを参照してください。
作成したグリッドで、ユーザーはデータを編集できるが、新しい行を追加できないようにするには、DataView をデータ ソースとして使用し、AllowNew プロパティを false に設定します。DataSource が DataView または DataTable の場合は、DataMember を空の文字列 ("") に設定します。

DataSource を DataSet に設定し、DataMember を、その DataSet 内の DataTable に設定するコード例を次に示します。
Private Sub BindControls() ' Create a DataSet named SuppliersProducts. Dim SuppliersProducts As New DataSet("SuppliersProducts") ' Adds two DataTable objects, Suppliers and Products. SuppliersProducts.Tables.Add(New DataTable("Suppliers")) SuppliersProducts.Tables.Add(New DataTable("Products")) ' Insert code to add DataColumn objects. ' Insert code to fill tables with columns and data. ' Binds the DataGrid to the DataSet, displaying the Suppliers table. dataGrid1.SetDataBinding(SuppliersProducts, "Suppliers") End Sub 'BindControls
private void BindControls(){ // Creates a DataSet named SuppliersProducts. DataSet SuppliersProducts = new DataSet("SuppliersProducts"); // Adds two DataTable objects, Suppliers and Products. SuppliersProducts.Tables.Add(new DataTable("Suppliers")); SuppliersProducts.Tables.Add(new DataTable("Products")); // Insert code to add DataColumn objects. // Insert code to fill tables with columns and data. // Binds the DataGrid to the DataSet, displaying the Suppliers table. dataGrid1.SetDataBinding(SuppliersProducts, "Suppliers"); }
private: void BindControls() { // Creates a DataSet named SuppliersProducts. DataSet^ SuppliersProducts = gcnew DataSet( "SuppliersProducts" ); // Adds two DataTable objects, Suppliers and Products. SuppliersProducts->Tables->Add( gcnew DataTable( "Suppliers" ) ); SuppliersProducts->Tables->Add( gcnew DataTable( "Products" ) ); // Insert code to add DataColumn objects. // Insert code to fill tables with columns and data. // Binds the DataGrid to the DataSet, displaying the Suppliers table. dataGrid1->SetDataBinding( SuppliersProducts, "Suppliers" ); }
private void BindControls() { // Creates a DataSet named SuppliersProducts. DataSet suppliersProducts = new DataSet("SuppliersProducts"); // Adds two DataTable objects, Suppliers and Products. suppliersProducts.get_Tables().Add(new DataTable("Suppliers")); suppliersProducts.get_Tables().Add(new DataTable("Products")); // Insert code to add DataColumn objects. // Insert code to fill tables with columns and data. // Binds the DataGrid to the DataSet, displaying the Suppliers table. dataGrid1.SetDataBinding(suppliersProducts, "Suppliers"); } //BindControls

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGrid.SetDataBinding メソッドを検索する場合は、下記のリンクをクリックしてください。

- DataGrid.SetDataBinding メソッドのページへのリンク