ListViewEditEventArgs.NewEditIndex 속성

정의

편집 중인 항목의 인덱스를 가져옵니다.

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

속성 값

Int32

편집 중인 항목의 인덱스입니다.

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다 합니다 NewEditIndex 검색할 속성의 ListViewItem 편집 중인 개체입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ListViewEditEventArgs 클래스입니다.

void ProductsListView_ItemEditing(Object sender, ListViewEditEventArgs e)
{
  ListViewItem item = ProductsListView.Items[e.NewEditIndex];
  Label dateLabel = (Label)item.FindControl("DiscontinuedDateLabel");
  
  if (String.IsNullOrEmpty(dateLabel.Text))
    return;
  
  //Verify if the item is discontinued.
  DateTime discontinuedDate = DateTime.Parse(dateLabel.Text);
  if (discontinuedDate < DateTime.Now)
  {
    Message.Text = "You cannot edit a discontinued item.";
    e.Cancel = true;
    ProductsListView.SelectedIndex = -1;
  }       
}
Sub ProductsListView_ItemEditing(ByVal sender As Object, ByVal e As ListViewEditEventArgs)
  Dim item As ListViewItem = ProductsListView.Items(e.NewEditIndex)
  Dim dateLabel As Label = CType(item.FindControl("DiscontinuedDateLabel"), Label)
    
  If String.IsNullOrEmpty(dateLabel.Text) Then _
    Return
    
  'Verify if the item is discontinued.
  Dim discontinuedDate As DateTime = DateTime.Parse(dateLabel.Text)
  If discontinuedDate < DateTime.Now Then
    Message.Text = "You cannot edit a discontinued item."
    e.Cancel = True
    ProductsListView.SelectedIndex = -1
  End If
End Sub

설명

사용 된 NewEditIndex 편집 중인 항목의 인덱스를 확인 하는 속성입니다. 이 항목에서 검색할 항목 인덱스는 대개는 Items 의 컬렉션을 ListView 컨트롤 항목의 속성에 액세스할 수 있습니다.

적용 대상

추가 정보