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

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

BindingSource.List プロパティ

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

コネクタバインド先であるリスト取得します

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

Dim instance As BindingSource
Dim value As IList

value = instance.List
public IList List { get; }
public:
property IList^ List {
    IList^ get ();
}
/** @property */
public IList get_List ()

プロパティ
リストを表す IList。この BindingSource に関連付けられている基底リストない場合null 参照 (Visual Basic では Nothing)。

解説解説

BindingSource クラスは、さまざまなデータ ソースを同じ方法処理しますList プロパティには、一般的な IList設定するのが理想的です。しかし、このプロパティをより特殊な型にキャストする必要がある場合あります次の表では、データ ソースの型または値に応じた基底リストの型を示します

データ ソースの型

基底リストに関する説明

DataSource と DataMember が null 参照 (Visual Basic では Nothing) です。

空の ArrayList。

DataSourcenull 参照 (Visual Basic では Nothing) ですが、DataMembernull 参照 (Visual Basic では Nothing) ではありません。

なし。List取得しようとすると ArgumentException がスローさます。

Arrayインスタンス

Array

IListSource のインスタンス

IListSource のこのインスタンスの GetList メソッドへの呼び出しによって返される値。

IBindingList のインスタンス

IBindingList

IListインスタンス

IList

"T" 型の IList 以外のインスタンス

1 つ要素を持つ BindingList。

ICustomTypeDescriptor のインスタンス

1 つ要素を持つ ArrayList

IEnumerable。

コピー上書きされる要素を持つ ArrayList

"T" 型の項目 DataMember を持つ Array 型。

BindingList

IListSource または ITypedList を表す Type

Activator クラスの CreateInstance メソッドへの呼び出しによって作成されるインスタンス。NotSupportedException がスローされる場合あります

"T" 型の項目 DataMember を持つ IList 型。

または

IList 以外の型。

BindingList

ICustomTypeDescriptor 型。

なし。List取得しようとすると NotSupportedExceptionスローさます。

取得した型が IList インターフェイスである場合基底コレクションは、ArrayList クラスや DataView クラスなどより複雑な型になります

使用例使用例

List、RemoveAt、および Count の各メンバコード例次に示します。この例を実行するには、BindingSource1 という名前の BindingSource持ちlabel1label2 という名前の 2 つラベル、および button1 という名前のボタン配置されているフォームコード貼り付けます。次にbutton1_Click メソッドbutton1Click イベント関連付けます。Visual Basic使用する場合、System.Data.dll への参照追加する必要があります

    Private Sub button1_Click(ByVal
 sender As Object, ByVal
 e As EventArgs) _
        Handles button1.Click

        ' Create the connection string, data adapter and data table.
        Dim connectionString As New
 SqlConnection("Initial Catalog=Northwind;" &
 _
            "Data Source=localhost;Integrated Security=SSPI;")
        Dim customersTableAdapter As New
 SqlDataAdapter("Select * from Customers", _
            connectionString)
        Dim customerTable As New
 DataTable()

        ' Fill the the adapter with the contents of the customer table.
        customersTableAdapter.Fill(customerTable)

        ' Set data source for BindingSource1.
        BindingSource1.DataSource = customerTable

        ' Set the label text to the number of items in the collection
 before
        ' an item is removed.
        label1.Text = "Starting count: " + BindingSource1.Count.ToString()

        'Access the List property and remove an item.
        BindingSource1.RemoveAt(4)

        ' Show the new count.
        label2.Text = "Count after removal: " + BindingSource1.Count.ToString()

    End Sub
End Class
private void button1_Click(object sender, EventArgs
 e)
{
    // Create the connection string, data adapter and data table.
    SqlConnection connectionString =
         new SqlConnection("Initial Catalog=Northwind;"
 +
         "Data Source=localhost;Integrated Security=SSPI;");
    SqlDataAdapter customersTableAdapter =
        new SqlDataAdapter("Select * from Customers",
 connectionString);
    DataTable customerTable = new DataTable();

    // Fill the the adapter with the contents of the customer table.
    customersTableAdapter.Fill(customerTable);

    // Set data source for BindingSource1.
    BindingSource1.DataSource = customerTable;

    // Set the label text to the number of items in the collection before
    // an item is removed.
    label1.Text = "Starting count: " + BindingSource1.Count.ToString();

    //Access the List property and remove an item.
    BindingSource1.RemoveAt(4);

    // Show the new count.
    label2.Text = "Count after removal: " + BindingSource1.Count.ToString();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingSource クラス
BindingSource メンバ
System.Windows.Forms 名前空間
IList
BindingSource.Item プロパティ



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2024 GRAS Group, Inc.RSS