BindingSource.DataSource プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As BindingSource Dim value As Object value = instance.DataSource instance.DataSource = value
/** @property */ public Object get_DataSource () /** @property */ public void set_DataSource (Object value)
データ ソースとして機能する Object。既定値は null 参照 (Visual Basic では Nothing) です。

DataSource プロパティには、複数のデータ ソース (型、オブジェクト、型のリストなど) を設定できます。設定されたデータ ソースは、リストとして公開されます。次の表は、共通のデータ ソースの一部と、評価の結果、作成されるリストの対応を示したものです。
DataSource プロパティ | |
---|---|
null 参照 (Visual Basic では Nothing) | |
null 参照 (Visual Basic では Nothing) (ただし DataMember が設定されている場合) | |
"T" 型の空の IBindingList。 | |
IEnumerable のインスタンス | IEnumerable の項目を含む IBindingList。 |
"T" 型を含む IBindingList のインスタンス。 |
また、DataSource は、IListSource や ITypedList など他のリスト型にも設定できます。BindingSource がこれらの型を適切に処理します。この場合、リストに含まれる型に既定のコンストラクタがあることを確認する必要があります。
データ ソースを設定するときに、指定した参照に複数のリストまたはテーブルが含まれている場合、DataMember プロパティにバインド先のリストを指定する文字列を設定する必要があります。このプロパティを設定すると、DataSourceChanged イベントが発生します。

顧客のリストを 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; }

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に収録されているすべての辞書からBindingSource.DataSource プロパティを検索する場合は、下記のリンクをクリックしてください。

- BindingSource.DataSource プロパティのページへのリンク