BindingManagerBase.RemoveAt(Int32) 方法

定義

當在衍生類別中覆寫時,刪除位於基礎清單中指定索引處的資料列。

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

參數

index
Int32

要刪除的資料列索引。

例外狀況

指定的 index 處並沒有資料列。

範例

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

備註

方法 RemoveAt 依賴基礎資料來源來判斷方法的行為。 (請參閱 類別,以取得 Binding 支援的資料來源清單。) 針對實 IList 作 、 IBindingListITypedList 的類別,以及實 IList 作 的強型別類別, RemoveAt 方法實際上會刪除基礎清單中的資料列,而不是移除其內容。

如果基礎清單實作 IBindingList 介面,屬性 AllowRemove 必須傳回 true 。 如果基礎清單實作 IList 介面,屬性 IsFixedSize 必須傳回 false

適用於

另請參閱