ListViewCancelEventArgs.ItemIndex 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 contains the Cancel button that raised the event.
public:
property int ItemIndex { int get(); };
public int ItemIndex { get; }
member this.ItemIndex : int
Public ReadOnly Property ItemIndex As Integer
Property Value
The zero-based index of the item that contains the Cancel button that raised the event.
Examples
The following example shows how to use the ItemIndex property to determine the index of the edit item that contains the Cancel button that was clicked by the user. This code example is part of a larger example provided for the ListViewCancelEventArgs class.
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
Remarks
Use the ItemIndex property to determine the index of the item that contains the Cancel button clicked by the user. The item index is often used to retrieve the item from the Items collection of the ListView control, which enables you to access the item's properties.
When the CancelMode property is set to ListViewCancelMode.CancelingInsert
, the value of the ItemIndex property is always -1.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기