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

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

BindingSource.RemoveAt メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

リスト内の指定したインデックスにある項目を削除します

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

Public Overridable Sub RemoveAt
 ( _
    index As Integer _
)
Dim instance As BindingSource
Dim index As Integer

instance.RemoveAt(index)
public virtual void RemoveAt (
    int index
)
public:
virtual void RemoveAt (
    int index
)
public void RemoveAt (
    int index
)

パラメータ

index

削除する項目の 0 から始まるインデックス

例外例外
例外種類条件

ArgumentOutOfRangeException

index が 0 未満か、または Count プロパティの値を上回ってます。

NotSupportedException

List プロパティ表される基底リストが、読み取り専用、または固定サイズです。

解説解説

これらの 2 つ条件確認するには、それぞれ IsFixedSize プロパティと IsReadOnly プロパティ使用します

このメソッドは、ListChanged イベント発生させます

使用例使用例

ListRemoveAt、および 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 名前空間
RemoveCurrent
Remove
List
IsFixedSize
IsReadOnly
IndexOf
Insert
Add
AddNew



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS