DataGridViewRowCollection.IList.Insert(Int32, Object) 메서드

정의

DataGridViewRow을 컬렉션에서 지정한 인덱스에 삽입합니다.

 virtual void System.Collections.IList.Insert(int index, System::Object ^ value) = System::Collections::IList::Insert;
void IList.Insert (int index, object value);
void IList.Insert (int index, object? value);
abstract member System.Collections.IList.Insert : int * obj -> unit
override this.System.Collections.IList.Insert : int * obj -> unit
Sub Insert (index As Integer, value As Object) Implements IList.Insert

매개 변수

index
Int32

value을 삽입해야 하는 인덱스(0부터 시작)입니다.

value
Object

DataGridViewRowCollection에 삽입할 DataGridViewRow입니다.

구현

예외

value이(가) DataGridViewRow가 아닌 경우

index 가 0보다 작거나 컬렉션의 행 수보다 큽니다.

value이(가) null인 경우

연결된 DataGridView 컨트롤이 일시적으로 새 행이 추가되지 않도록 하는 다음 작업 중 하나를 수행합니다.

  • 컨트롤의 모든 셀 선택

  • 선택 영역 지우기

또는

이 메서드는 다음 DataGridView 이벤트 중 하나의 처리기에서 호출됩니다.

또는

DataSourceDataGridView 속성이 null이 아닙니다.

또는

index 가 컬렉션의 행 수와 같고 AllowUserToAddRowsDataGridView 속성이 true로 설정되었습니다.

또는

DataGridView 에 열이 없습니다.

또는

DataGridViewvalue 속성이 null이 아닙니다.

또는

valueSelectedtrue속성 값이 있습니다.

또는

이 작업에서는 고정되지 않은 행 뒤에 고정된 행을 삽입하거나 고정된 행 앞에 고정되지 않은 행을 삽입합니다.

value 에 컨트롤에 있는 열보다 많은 셀이 포함되어 있습니다.

설명

이 멤버는 명시적 인터페이스 멤버 구현이며, DataGridViewRowCollection 인스턴스가 IList 인터페이스로 캐스팅된 경우에만 사용할 수 있습니다.

이 메서드는 오버로드를 호출하여 Insert(Int32, DataGridViewRow) 에 캐스팅 DataGridViewRow한 후 값을 전달합니다.

컨트롤의 행은 새 행이 추가될 때 자동으로 정렬되지 않습니다. 새 행을 올바른 위치로 정렬하려면 이벤트 처리기에서 메서드를 DataGridView.RowsAdded 호출 DataGridView.Sort 합니다. 사용자가 셀을 DataGridView.Sort 수정할 때 이벤트 처리기에서 CellValueChanged 메서드를 호출하여 행을 정렬할 수도 있습니다.

적용 대상

추가 정보