AfterLabelEdit Event (ListView, TreeView Controls)

       

Occurs after a user edits the label of the currently selected Node or ListItem object.

Syntax

Private Sub object_AfterLabelEdit(cancel As Integer, newstring As String)

The AfterLabelEdit event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
cancel An integer that determines if the label editing operation is canceled. Any nonzero integer cancels the operation. Boolean values are also accepted.
newstring The string the user entered, or Null if the user canceled the operation.

Remarks

Both the AfterLabelEdit and the BeforeLabelEdit events are generated only if the LabelEdit property is set to 0 (Automatic), or if the StartLabelEdit method is invoked.

The AfterLabelEdit event is generated after the user finishes the editing operation, which occurs when the user clicks on another Node or ListItem or presses the ENTER key.

To cancel a label editing operation, set cancel to any nonzero number or to True. If a label editing operation is canceled, the previously existing label is restored.

The newstring argument can be used to test for a condition before canceling an operation. For example, the following code cancels the operation if newstring is a number:

Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String)
   If IsNumeric(NewString) Then
      MsgBox "No numbers allowed"
      Cancel = True
   End If
End Sub