情報
要求されたトピックは次のとおりです。しかし、このトピックはこのライブラリには含まれていません。
1 人のうち 0 人が、- このトピックを評価する が役に立ったと評価しました

BindingSource.DataSource プロパティ

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

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

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

public Object DataSource { get; set; }
/** @property */
public Object get_DataSource ()

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

public function get DataSource () : Object

public function set DataSource (value : Object)

プロパティ値

データ ソースとして機能する 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 は、IListSourceITypedList など他のリスト型にも設定できます。BindingSource がこれらの型を適切に処理します。この場合、リストに含まれる型に既定のコンストラクタがあることを確認する必要があります。

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

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

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

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;
}

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

.NET Framework

サポート対象 : 2.0

.NET Compact Framework

サポート対象 : 2.0
この情報は役に立ちましたか。
(残り 1500 文字)

コミュニティの追加

© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter