Επεξεργασία

Κοινή χρήση μέσω


CurrencyManager.RemoveAt(Int32) Method

Definition

Removes the item at the specified index.

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

Parameters

index
Int32

The index of the item to remove from the list.

Exceptions

There is no row at the specified index.

Examples

The following code example uses the RemoveAt method to remove the item at position 0 in the list.

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

Remarks

The RemoveAt method was designed to allow complex controls, such as the DataGrid control, to remove items from the list. You should not use this method to actually remove items. Instead, use the Delete method of the DataView class to delete items.

Applies to

See also