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 类以获取支持的数据源列表。) 对于实现 IListIBindingListITypedList的类以及实现 IList的强类型类, RemoveAt 方法实际上会删除基础列表中的行,而不是删除其内容。

如果基础列表实现 IBindingList 接口,则 AllowRemove 属性必须返回 true。 如果基础列表实现 IList 接口,则 IsFixedSize 属性必须返回 false

适用于

另请参阅