Skip to content

OnEndLabelEdit - AbstractTreeView

Fired if the user completes the edit when user performs in-line editing of the label

Type: Event

Parameters

Parameter Type Description
hItem Handle Item handle
sNewLabel String The new label value
bWasCanceled Boolean Returns True if the edit was canceled by the user
ByRef bCancel Boolean Can be used to cancel the event by returning True

Syntax

Procedure OnEndLabelEdit Handle hItem String sNewLabel Boolean bWasCanceled ByRef Boolean bCancel

Description

If a user performs in-line editing of the label (TreeEditLabelsState must be True), the OnEndLabelEdit event will be fired if the user completes the edit.

bWasCanceled determines how the edit was terminated. If True, the user canceled the edit (this is also returned True if no edit was made - this is how Windows does it).

The new label value is passed as a parameter. The existing label value can be obtained by using ItemLabel.

Sample

Procedure OnBeginLabelEdit Handle hItem Boolean ByRef bCancel
    Handle hRoot

    // if user is editing the root, don't allow and declare an error
    Get RootItem to hRoot
    If (hItem=hRoot) Begin
        Error DFERR_OPERATOR "Cannot change the root Label"
        Move True to bCancel
    End
End_Procedure

Procedure OnEndLabelEdit Handle hItem String sNewLabel Boolean bWasCanceled Boolean ByRef bCancel
    String sOriginalLabel

    If (not(bWasCanceled)) Begin
        // get old value of the label
        Get ItemLabel hItem to sOriginalLabel
        // don't allow edit to be blank 
        If (sNewLabel="") Begin
            Error DFERR_OPERATOR "Blank labels not allowed"
            Move True to bCancel
        End
        Else If (sOriginalLabel=sNewLabel) Begin
            // if no change, complain
            Error DFERR_OPERATOR "You did not change anything"
        End
    End
    Else Begin
        // This really isn't an error, but you get the idea
        Error DFERR_OPERATOR "Cancelled by User"
    End    
End_Procedure

Sample

This sample demonstrates the use of the bCancel parameter to cancel the editing of a TreeView item label.

Procedure OnEndLabelEdit Handle hItem String sNewLabel Boolean bWasCanceled Boolean ByRef bCancel
    Move True to bCancel
End_Procedure

See Also

OnBeginLabelEdit | pbCancelEdit | TreeEditLabelsState | ItemLabel