ListViewCancelEventArgs.ItemIndex 속성

정의

이벤트를 발생시킨 취소 단추가 들어 있는 항목의 인덱스를 가져옵니다.

public:
 property int ItemIndex { int get(); };
public int ItemIndex { get; }
member this.ItemIndex : int
Public ReadOnly Property ItemIndex As Integer

속성 값

Int32

이벤트를 발생시킨 취소 단추가 들어 있는 항목의 인덱스(0부터 시작)입니다.

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다는 ItemIndex 속성을 사용자가 클릭 한 취소 단추를 포함 하는 편집 항목의 인덱스를 확인 합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ListViewCancelEventArgs 클래스입니다.

protected void ContactsListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
  //Check the operation that raised the event
  if (e.CancelMode == ListViewCancelMode.CancelingEdit)
  {
    // The update operation was canceled. Display the 
    // primary key of the item.
    Message.Text = "Update for the ContactID " + 
      ContactsListView.DataKeys[e.ItemIndex].Value.ToString()  + " canceled.";
  }
  else
  {
    Message.Text = "Insert operation canceled."; 
  }
}
Protected Sub ContactsListView_ItemCanceling(ByVal sender As Object, _
                                             ByVal e As ListViewCancelEventArgs)
  'Check the operation that raised the event
  If (e.CancelMode = ListViewCancelMode.CancelingEdit) Then
    ' The update operation was canceled. Display the 
    ' primary key of the item.
    Message.Text = "Update for the ContactID " & _
      ContactsListView.DataKeys(e.ItemIndex).Value.ToString() & " canceled."
  Else
    Message.Text = "Insert operation canceled."
  End If

End Sub

설명

사용 된 ItemIndex 취소 단추가 들어 있는 항목의 인덱스를 확인 하는 속성은 사용자가 클릭 합니다. 항목 인덱스에서 항목을 검색 하는 대개 합니다 Items 의 컬렉션을 ListView 컨트롤 항목의 속성에 액세스할 수 있습니다.

경우는 CancelMode 속성이로 설정 되어 ListViewCancelMode.CancelingInsert의 값은 ItemIndex 속성은 항상-1입니다.

적용 대상

추가 정보