BindingSource.RemoveAt メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)




List、RemoveAt、および Count の各メンバのコード例を次に示します。この例を実行するには、BindingSource1 という名前の BindingSource を持ち、label1 と label2 という名前の 2 つのラベル、および button1 という名前のボタンが配置されているフォームにコードを貼り付けます。次に、button1_Click メソッドを button1 の Click イベントに関連付けます。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(); }

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.RemoveAt メソッドを検索する場合は、下記のリンクをクリックしてください。

- BindingSource.RemoveAt メソッドのページへのリンク