BindingManagerBase.RemoveAt(Int32) Metodo

Definizione

Quando viene sottoposto a override in una classe derivata, elimina la riga in corrispondenza dell'indice specificato dall'elenco sottostante.

public:
 abstract void RemoveAt(int index);
public abstract void RemoveAt (int index);
abstract member RemoveAt : int -> unit
Public MustOverride Sub RemoveAt (index As Integer)

Parametri

index
Int32

Indice della riga da eliminare.

Eccezioni

Non esiste alcuna riga in corrispondenza del parametro index specificato.

Esempio

void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   try
   {
      // Get the 'BindingManagerBase' Object*.
      BindingManagerBase^ myBindingManagerBase = BindingContext[ myDataTable ];

      // Remove the selected row from the grid.
      myBindingManagerBase->RemoveAt( myBindingManagerBase->Position );
   }
   catch ( Exception^ ex ) 
   {
      MessageBox::Show( ex->Source );
      MessageBox::Show( ex->Message );
   }
}
private void button1_Click(object sender, System.EventArgs e)
{
   try
   {
      // Get the 'BindingManagerBase' object.
      BindingManagerBase myBindingManagerBase=BindingContext[myDataTable];
      // Remove the selected row from the grid.
      myBindingManagerBase.RemoveAt(myBindingManagerBase.Position);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Source);
      MessageBox.Show(ex.Message);
   }
}
Private Sub button1_Click(sender As Object, e As EventArgs)
   Try
      ' Get the 'BindingManagerBase' object.
      Dim myBindingManagerBase As BindingManagerBase = BindingContext(myDataTable)
      ' Remove the selected row from the grid.
      myBindingManagerBase.RemoveAt(myBindingManagerBase.Position)
   Catch ex As Exception
      MessageBox.Show(ex.Source)
      MessageBox.Show(ex.Message)
   End Try
End Sub

Commenti

Il RemoveAt metodo si basa sull'origine dati sottostante per determinare il comportamento del metodo. Vedere la Binding classe per un elenco di origini dati supportate. Per le classi che implementano IList, IBindingListo ITypedListo , nonché classi fortemente tipizzata che implementano IList, il RemoveAt metodo elimina effettivamente la riga nell'elenco sottostante anziché rimuovere il relativo contenuto.

Se l'elenco sottostante implementa l'interfaccia IBindingList , la AllowRemove proprietà deve restituire true. Se l'elenco sottostante implementa l'interfaccia IList , la IsFixedSize proprietà deve restituire false.

Si applica a

Vedi anche