LabelEditEventArgs.Item 屬性

定義

取得 ListViewItem 的以零起始的索引,包含要編輯的標籤。

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

屬性值

ListViewItem 的以零起始的索引。

範例

下列程式碼範例示範如何處理 ListView.BeforeLabelEdit 事件和使用 ItemCancelEdit 屬性。 若要執行此範例,請將下列程式碼貼到包含名為 ListView1 之 ListView 控制項的表單中,並填入至少 3 個專案。 確定所有事件都與其事件處理方法相關聯。

void ListView1_BeforeLabelEdit( Object^ sender,
   System::Windows::Forms::LabelEditEventArgs^ e )
{
   // Allow all but the first two items of the list to 
   // be modified by the user.
   if ( e->Item < 2 )
   {
      e->CancelEdit = true;
   }
}
private void ListView1_BeforeLabelEdit(object sender, 
    System.Windows.Forms.LabelEditEventArgs e)
{
    // Allow all but the first two items of the list to 
    // be modified by the user.
    if (e.Item<2)
    {
        e.CancelEdit = true;
    }
}

Private Sub ListView1_BeforeLabelEdit(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.LabelEditEventArgs) _
    Handles ListView1.BeforeLabelEdit

    ' Allow all but the first two items of the list to be modified by
    ' the user.
    If (e.Item < 2) Then
        e.CancelEdit = True
    End If
End Sub

適用於