Condividi tramite


BindingManagerBase.RemoveAt(Int32) Metodo

Definizione

Quando 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 dell'oggetto specificato index.

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. Per un elenco delle origini dati supportate, vedere la Binding classe . Per le classi che implementano IList, IBindingListo ITypedList, nonché classi fortemente tipate che implementano IList, il RemoveAt metodo elimina effettivamente la riga nell'elenco sottostante invece di rimuoverlo.

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