Metodo BindingSource.RemoveAt
Assembly: System.Windows.Forms (in system.windows.forms.dll)
È possibile verificare queste due condizioni utilizzando rispettivamente le proprietà IsFixedSize e IsReadOnly.
Questo metodo genera l'evento ListChanged.
Nell'esempio di codice riportato di seguito vengono illustrati i membri List, RemoveAt e Count. Per eseguire l'esempio, incollare il codice in un form contenente un oggetto BindingSource denominato BindingSource1, due etichette denominate label1 e label2 e un pulsante denominato button1. Associare il metodo button1_Click all'evento Click per button1. Gli utenti di Visual Basic devono aggiungere un riferimento a System.Data.dll.
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 per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.