BindingSource.DataSource プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BindingSource.DataSource プロパティの意味・解説 

BindingSource.DataSource プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

コネクタバインド先であるデータ ソース取得または設定します

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

Dim instance As BindingSource
Dim value As Object

value = instance.DataSource

instance.DataSource = value
public Object DataSource { get; set;
 }
/** @property */
public Object get_DataSource ()

/** @property */
public void set_DataSource (Object value)

プロパティ
データ ソースとして機能する Object既定値null 参照 (Visual Basic では Nothing) です。

解説解説

DataSource プロパティには、複数データ ソース (型、オブジェクト、型のリストなど) を設定できます設定されデータ ソースは、リストとして公開されます。次の表は、共通のデータ ソース一部と、評価結果作成されるリストの対応を示したものです。

DataSource プロパティ

作成されるリスト

null 参照 (Visual Basic では Nothing)

オブジェクトの空の IBindingList。項目を追加すると、リストが、追加された項目の型に設定されます。

null 参照 (Visual Basic では Nothing) (ただし DataMember が設定されている場合)

サポートされていません。ArgumentException が発生します

リスト以外の型または "T" 型のオブジェクト

"T" 型の空の IBindingList

配列インスタンス

配列要素を含む IBindingList

IEnumerable のインスタンス

IEnumerable の項目を含む IBindingList

"T" 型を含むリストインスタンス

"T" 型を含む IBindingListインスタンス

また、DataSource は、IListSource や ITypedList など他のリスト型にも設定できます。BindingSource がこれらの型を適切に処理します。この場合リスト含まれる型に既定コンストラクタがあることを確認する必要があります

データ ソース設定するときに、指定した参照複数リストまたはテーブル含まれている場合DataMember プロパティバインド先のリスト指定する文字列設定する必要があります。このプロパティ設定すると、DataSourceChanged イベント発生します

DataSource プロパティは、BindingSource クラス既定プロパティです。

使用例使用例

顧客リストBindingSource コンポーネントDataSource割り当てるコード例次に示します。このコード例は、「方法 : BindingSource ResetItem メソッド使用して変更通知発生させる」の例の一部です。

Private Sub Form1_Load(ByVal
 sender As System.Object, _
    ByVal e As System.EventArgs) Handles
 Me.Load
    ' Create and populate the list of DemoCustomer objects
    ' which will supply data to the DataGridView.
    Dim customerList As List(Of
 DemoCustomer) = _
    New List(Of DemoCustomer)
    customerList.Add(DemoCustomer.CreateNewCustomer())
    customerList.Add(DemoCustomer.CreateNewCustomer())
    customerList.Add(DemoCustomer.CreateNewCustomer())

    ' Bind the list to the BindingSource.
    Me.customersBindingSource.DataSource = customerList

    ' Attach the BindingSource to the DataGridView.
    Me.customersDataGridView.DataSource = Me.customersBindingSource
End Sub
private void Form1_Load(System.Object sender,
 System.EventArgs e)
{
    // Create and populate the list of DemoCustomer objects
    // which will supply data to the DataGridView.
    List<DemoCustomer> customerList = new List<DemoCustomer>();
    customerList.Add(DemoCustomer.CreateNewCustomer());
    customerList.Add(DemoCustomer.CreateNewCustomer());
    customerList.Add(DemoCustomer.CreateNewCustomer());

    // Bind the list to the BindingSource.
    this.customersBindingSource.DataSource = customerList;

    
    // Attach the BindingSource to the DataGridView.
    this.customersDataGridView.DataSource = 
        this.customersBindingSource;
}
void Form1_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Create and populate the list of DemoCustomer objects
   // which will supply data to the DataGridView.
   List< DemoCustomer^ >^ customerList = gcnew List< DemoCustomer^ >;
   customerList->Add( DemoCustomer::CreateNewCustomer() );
   customerList->Add( DemoCustomer::CreateNewCustomer() );
   customerList->Add( DemoCustomer::CreateNewCustomer() );
   
   // Bind the list to the BindingSource.
   this->customersBindingSource->DataSource = customerList;
   
   // Handle the ListChanged event.
   this->customersBindingSource->ListChanged +=
      gcnew ListChangedEventHandler(
         this, &Form1::customersBindingSource_ListChanged
 );
   
   // Attach the BindingSource to the DataGridView.
   this->customersDataGridView->DataSource =
      this->customersBindingSource;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingSource クラス
BindingSource メンバ
System.Windows.Forms 名前空間
BindingSource.DataMember プロパティ
IList
IListSource


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

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

辞書ショートカット

すべての辞書の索引

「BindingSource.DataSource プロパティ」の関連用語

BindingSource.DataSource プロパティのお隣キーワード
検索ランキング

   

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



BindingSource.DataSource プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS