DataRowCollection.RemoveAt(Int32) 메서드

정의

컬렉션에서 지정된 인덱스의 행을 제거합니다.

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

매개 변수

index
Int32

제거할 행의 인덱스입니다.

예제

다음 예제에서는 메서드를 호출하여 의 DataRowCollection 마지막 행을 제거합니다 RemoveAt .

 Private Sub RemoveRowByIndex()
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim rowCollection As DataRowCollection = table.Rows
    If rowCollection.Count = 0 Then 
        Exit Sub
    End If
    rowCollection.RemoveAt(rowCollection.Count - 1)
End Sub

설명

행이 제거되면 해당 행의 모든 데이터가 손실됩니다. 클래스의 DataRow 메서드를 Delete 호출하여 제거를 위해 행을 표시할 수도 있습니다. 호출 RemoveAt 은 를 호출한 다음 를 호출 DeleteAcceptChanges하는 것과 동일합니다.

메서드를 Clear 사용하여 컬렉션의 모든 멤버를 한 번에 제거할 수 있습니다.

적용 대상

추가 정보