CurrencyManager.RemoveAt(Int32) 方法

定义

删除指定索引处的项。

public:
 override void RemoveAt(int index);
public override void RemoveAt (int index);
override this.RemoveAt : int -> unit
Public Overrides Sub RemoveAt (index As Integer)

参数

index
Int32

要从列表中移除的项的索引。

例外

指定的 index 处没有行。

示例

下面的代码示例使用 RemoveAt 该方法删除列表中位置 0 处的项。

void RemoveFromList()
{
   
   // Get the CurrencyManager of a TextBox control.
   CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(textBox1->BindingContext[nullptr]);
   
   // If the count is 0, exit the function.
   if ( myCurrencyManager->Count > 1 )
         myCurrencyManager->RemoveAt( 0 );
}
private void RemoveFromList(){
    // Get the CurrencyManager of a TextBox control.
    CurrencyManager myCurrencyManager = (CurrencyManager)textBox1.BindingContext[0];
    // If the count is 0, exit the function.
    if(myCurrencyManager.Count > 1)
    myCurrencyManager.RemoveAt(0);
}
Private Sub RemoveFromList()
    ' Get the CurrencyManager of a TextBox control.
    Dim myCurrencyManager As CurrencyManager = CType(textBox1.BindingContext(0), CurrencyManager)
    ' If the count is 0, exit the function.
    If myCurrencyManager.Count > 1 Then
        myCurrencyManager.RemoveAt(0)
    End If
    
End Sub

注解

该方法 RemoveAt 旨在允许复杂控件(如 DataGrid 控件)从列表中删除项。 不应使用此方法来实际删除项。 请改用 Delete 类的方法 DataView 删除项。

适用于

另请参阅