ListViewEditEventArgs.NewEditIndex Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the index of the item that is being edited.
public:
property int NewEditIndex { int get(); };
public int NewEditIndex { get; }
member this.NewEditIndex : int
Public ReadOnly Property NewEditIndex As Integer
Property Value
The index of the item that is being edited.
Examples
The following example shows how to use the NewEditIndex property to retrieve the ListViewItem object that is being edited. This code example is part of a larger example provided for the ListViewEditEventArgs class.
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
Remarks
Use the NewEditIndex property to determine the index of the item that is being edited. The item index is often used to retrieve this item from the Items collection of the ListView control, which enables you to access the item's properties.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기