共用方式為


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 方法來刪除專案。

適用於

另請參閱