Returns or sets a value that determines if a user can edit labels of ListItem or Node objects in a ListView or TreeView control.
object.LabelEdit [ = integer]
object.StartLabelEdit
object:ListView, TreeView
Label editing of an object is initiated when a selected object is clicked (if the LabelEdit property is set to Automatic). That is, the first click on an object will select it; a second (single) click on the object will initiate the label editing operation.
LabelEdit can have the following values:
0 - Automatic (Default). The BeforeLabelEdit event is generated when the user clicks the label of a selected node.
1 - Manual. The BeforeLabelEdit event is generated only when the StartLabelEdit method is invoked.
The LabelEdit property, in combination with the StartLabelEdit method, allows you to programmatically determine when and which labels can be edited. When the LabelEdit property is set to 1, no label can be edited unless the StartLabelEdit method is invoked.
Global li As ListItem, n As Int32
OpenW 1
Ocx ListView lv = "", 10, 10, 200, 300 : .View = 3 : .GridLines = True : .FullRowSelect = True
lv.ColumnHeaders.Add , , "Column1" : lv.ColumnHeaders.Add , , "Column2"
For n = 1 To 20
lv.ListItems.Add , n , "Item " & Format(n, "00")
Next n
Ocx Command cmd1 = "Disable Label Editing", 220, 10, 140, 22
Ocx Command cmd2 = "Manually Edit Selected Item", 220, 35, 140, 22
Do : Sleep : Until IsNothing(Win_1)
Sub cmd1_Click
cmd1.Caption = (lv.LabelEdit = 1 ? "Disable" : "Enable") & " Label Editing"
lv.LabelEdit = 1 - lv.LabelEdit
EndSub
Sub cmd2_Click
If lv.SelectedCount <> 0
lv.SetFocus
lv.StartLabelEdit // Error: Only works when LabelEdit = 0
EndIf
EndSub
Rather than opening a label for editing for all values of LabelEdit as happens in VB6, StartLabelEdit only seems to work when LabelEdit = 0.
ListView, TreeView, BeforeLabelEdit, AfterLabelEdit
{Created by Sjouke Hamstra; Last updated: 11/10/2014 by James Gaite}