BindingManagerBase.RemoveAt(Int32) Metoda

Definicja

Po zastąpieniu w klasie pochodnej usuwa wiersz w określonym indeksie z listy bazowej.

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

Parametry

index
Int32

Indeks wiersza do usunięcia.

Wyjątki

W określonym pliku indexnie ma wiersza .

Przykłady

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

Uwagi

Metoda RemoveAt opiera się na bazowym źródle danych, aby określić, jak działa metoda. (Zobacz klasę, Binding aby uzyskać listę obsługiwanych źródeł danych). W przypadku klas implementujących IListklasy , IBindingListlub , ITypedLista także silnie typizowane klasy, które implementują IList, RemoveAt metoda faktycznie usuwa wiersz na liście bazowej zamiast usuwać jego zawartość.

Jeśli podstawowa lista implementuje IBindingList interfejs, AllowRemove właściwość musi zwrócić truewartość . Jeśli podstawowa lista implementuje IList interfejs, IsFixedSize właściwość musi zwrócić falsewartość .

Dotyczy

Zobacz też