DataGrid.SetDataBinding メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGrid.SetDataBinding メソッドの意味・解説 

DataGrid.SetDataBinding メソッド

実行時DataSource プロパティDataMember プロパティ設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub SetDataBinding ( _
    dataSource As Object, _
    dataMember As String _
)
Dim instance As DataGrid
Dim dataSource As Object
Dim dataMember As String

instance.SetDataBinding(dataSource, dataMember)
public void SetDataBinding (
    Object dataSource,
    string dataMember
)
public:
void SetDataBinding (
    Object^ dataSource, 
    String^ dataMember
)
public void SetDataBinding (
    Object dataSource, 
    String dataMember
)
public function SetDataBinding (
    dataSource : Object, 
    dataMember : String
)

パラメータ

dataSource

System.Windows.Forms.DataGrid コントロールデータ ソース

dataMember

DataSource プロパティによって返されオブジェクト内で、バインド先のテーブル指定する DataMember 文字列

例外例外
例外種類条件

ArgumentException

1 つ上の引数無効です。

ArgumentNullException

dataSource 引数null 参照 (Visual Basic では Nothing) です。

解説解説

実行時SetDataBinding メソッド使用してDataSource プロパティリセットする必要があります

有効なデータ ソース設定する方法詳細については、DataSource プロパティトピック参照してください

作成したグリッドで、ユーザーデータ編集できるが、新しい行を追加できないようにするには、DataView をデータ ソースとして使用し、AllowNew プロパティfalse設定しますDataSourceDataView または DataTable の場合は、DataMember空の文字列 ("") に設定します

使用例使用例

DataSourceDataSet設定し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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGrid クラス
DataGrid メンバ
System.Windows.Forms 名前空間
DataMember
DataSource
DataSet
DataView


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGrid.SetDataBinding メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGrid.SetDataBinding メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGrid.SetDataBinding メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataGrid.SetDataBinding メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGrid.SetDataBinding メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS