LabelEditEventArgs.Item 属性

获取 ListViewItem(它包含要编辑的标签)的从零开始的索引。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public ReadOnly Property Item As Integer
用法
Dim instance As LabelEditEventArgs
Dim value As Integer

value = instance.Item
public int Item { get; }
public:
property int Item {
    int get ();
}
/** @property */
public int get_Item ()
public function get Item () : int

属性值

ListViewItem 的从零开始的索引。

示例

下面的代码示例演示如何处理 ListView.BeforeLabelEdit 事件以及使用 ItemCancelEdit 属性。要运行该示例,请将以下代码粘贴到一个窗体中,而该窗体包含名为 ListView1 并且至少填充了 3 项的 ListView 控件。确保所有事件均与其事件处理方法相关联。

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
   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;
    }
}
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.get_Item() < 2) {
        e.set_CancelEdit(true);
    }
} //listView1_BeforeLabelEdit

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

LabelEditEventArgs 类
LabelEditEventArgs 成员
System.Windows.Forms 命名空间