BindingSource.RemoveAt, méthode
Assembly : System.Windows.Forms (dans system.windows.forms.dll)
Ces deux conditions peuvent être testées par les propriétés IsFixedSize et IsReadOnly, respectivement.
Cette méthode déclenche l'événement ListChanged.
L'exemple de code suivant illustre les membres List, RemoveAt et Count. Pour exécuter cet exemple, collez le code dans un formulaire qui contient un BindingSource nommé BindingSource1, deux étiquettes nommées label1 et label2 et un bouton nommé button1. Associez la méthode button1_Click à l'événement Click de button1. Les utilisateurs de Visual Basic devront ajouter une référence à 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 pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.