LabelEditEventArgs LabelEditEventArgs LabelEditEventArgs LabelEditEventArgs Class

定义

提供有关 BeforeLabelEditAfterLabelEdit 事件的数据。Provides data for the BeforeLabelEdit and AfterLabelEdit events.

public ref class LabelEditEventArgs : EventArgs
public class LabelEditEventArgs : EventArgs
type LabelEditEventArgs = class
    inherit EventArgs
Public Class LabelEditEventArgs
Inherits EventArgs
继承
LabelEditEventArgsLabelEditEventArgsLabelEditEventArgsLabelEditEventArgs

示例

下面的代码示例演示了如何处理ListView.BeforeLabelEdit事件并使用ItemCancelEdit属性。The following code example demonstrates handling the ListView.BeforeLabelEdit event and using the Item and CancelEdit properties. 若要运行该示例,请将以下代码粘贴在一个窗体,其中包含ListView名为控件ListView1和填充至少 3 个项。To run the example, paste the following code in a form containing a ListView control named ListView1 and populated with at least 3 items. 请确保所有事件都都具有其事件处理方法关联。Ensure all events are associated with their event-handling methods.

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

注解

一个LabelEditEventArgs指定的索引和标题的ListViewItem和用户编辑后的标题。A LabelEditEventArgs specifies the index and caption of a ListViewItem and the caption after it has been edited by the user. 此类还提供CancelEdit属性。This class also provides a CancelEdit property. 可以使用此属性在ListView.BeforeLabelEdit事件处理程序以阻止用户编辑标签。You can use this property in a ListView.BeforeLabelEdit event handler to prevent the user from editing the label. 此外可以使用它在ListView.AfterLabelEdit事件处理程序可撤消更改,返回标签到其原始值。You can also use it in an ListView.AfterLabelEdit event handler to revert the change, returning the label it to its original value. 当你想要提交更改前验证用户输入时,这很有用。This is useful when you want to validate user input before committing the change.

备注

因为ListView.AfterLabelEdit事件发生之前就会提交,调用标签编辑ListView.Sort此事件的处理程序中的方法将对使用原始值的项进行排序。Because the ListView.AfterLabelEdit event takes place before the label edit is committed, calling the ListView.Sort method in a handler for this event will sort the item using the original value.

构造函数

LabelEditEventArgs(Int32) LabelEditEventArgs(Int32) LabelEditEventArgs(Int32) LabelEditEventArgs(Int32)

使用要编辑的 LabelEditEventArgs 的指定索引初始化 ListViewItem 类的新实例。Initializes a new instance of the LabelEditEventArgs class with the specified index to the ListViewItem to edit.

LabelEditEventArgs(Int32, String) LabelEditEventArgs(Int32, String) LabelEditEventArgs(Int32, String) LabelEditEventArgs(Int32, String)

使用正在被编辑的 LabelEditEventArgs 的指定索引和 ListViewItem 标签的新文本初始化 ListViewItem 类的新实例。Initializes a new instance of the LabelEditEventArgs class with the specified index to the ListViewItem being edited and the new text for the label of the ListViewItem.

属性

CancelEdit CancelEdit CancelEdit CancelEdit

获取或设置一个值,该值指示是否应取消对 ListViewItem 的标签所作的更改。Gets or sets a value indicating whether changes made to the label of the ListViewItem should be canceled.

Item Item Item Item

获取 ListViewItem(它包含要编辑的标签)的从零开始的索引。Gets the zero-based index of the ListViewItem containing the label to edit.

Label Label Label Label

获取分配给 ListViewItem 的标签的新文本。Gets the new text assigned to the label of the ListViewItem.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于

另请参阅