Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

NodeLabelEditEventArgs Class

Provides data for the BeforeLabelEdit and AfterLabelEdit events.


Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

type NodeLabelEditEventArgs =  
        inherit EventArgs 

The NodeLabelEditEventArgs type exposes the following members.

Public methodNodeLabelEditEventArgs(TreeNode)Initializes a new instance of the NodeLabelEditEventArgs class for the specified TreeNode.
Public methodNodeLabelEditEventArgs(TreeNode, String)Initializes a new instance of the NodeLabelEditEventArgs class for the specified TreeNode and the specified text with which to update the tree node label.

Public propertyCancelEditGets or sets a value indicating whether the edit has been canceled.
Public propertyLabelGets the new text to associate with the tree node.
Public propertyNodeGets the tree node containing the text to edit.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The AfterLabelEdit event occurs when the user finishes editing the text for a tree node. The BeforeLabelEdit event occurs when the user begins editing the text for a tree node. A NodeLabelEditEventArgs object specifies the new text to associate with the tree node, the tree node that contains the label to edit, and whether the edit operation has been canceled.

For more information about handling events, see Handling and Raising Events.

The following example allows the user to edit nonroot tree nodes by using a ContextMenu. When the user right clicks the mouse, the TreeNode at that position is determined and stored in a variable named mySelectedNode. If a nonroot tree node was selected, it is put into an editable state, allowing the user to edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft