Programmatically edit a treeview label: Difference between revisions
From DataFlex Wiki
Jump to navigationJump to search
Programmatically edit a treeview label (view source)
Revision as of 12:46, 25 March 2020
, 25 March 2020Added to Tutorials category
(New page: ====The problem==== The normal treeview class does not have a method of putting your treeview item into "edit mode" programmatically. Of course you can do this in the treeview when you are...) |
Hsymington (talk | contribs) m (Added to Tutorials category) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 9: | Line 9: | ||
First you have to enable label editing with: | First you have to enable label editing with: | ||
<source lang="vdf"> | |||
Set TreeEditLabelsState to True | Set TreeEditLabelsState to True | ||
</source> | |||
Then you have to send TVM_EDITLABEL for example as in: | |||
<source lang="vdf"> | |||
Procedure EditNow | Procedure EditNow | ||
Handle hItem | Handle hItem | ||
Handle hWnd | |||
Integer iResult | |||
Get CurrentTreeItem to hItem | Get CurrentTreeItem to hItem | ||
Get Window_Handle to hWnd | |||
Move (SendMessage(hWnd,TVM_EDITLABEL,0,hItem)) to iResult | |||
End_Procedure | End_Procedure | ||
On_Key Key_Alt+Key_F1 Send EditNow | On_Key Key_Alt+Key_F1 Send EditNow | ||
</source> | |||
As you can see I've not tested with doing it just after adding the item but | As you can see I've not tested with doing it just after adding the item but | ||
Line 36: | Line 42: | ||
Correct syntax would be | Correct syntax would be | ||
Procedure | <source lang="vdf"> | ||
Procedure AddAndEditItem | |||
Handle hItem | Handle hItem | ||
Get AddTreeItem of oTreeView1 "New item" 0 0 0 0 To hItem | Get AddTreeItem of oTreeView1 "New item" 0 0 0 0 To hItem | ||
Set ItemData of oTreeView1 Item hItem to 999 | Set ItemData of oTreeView1 Item hItem to 999 | ||
Get Window_Handle of oTreeView1 to hWnd | Get Window_Handle of oTreeView1 to hWnd | ||
If (hWnd <> 0) Begin | If (hWnd <> 0) Begin | ||
Line 48: | Line 55: | ||
End | End | ||
End_Procedure | End_Procedure | ||
</source> | |||
Depending on the version of VDF you are using you have the following events and | Depending on the version of VDF you are using you have the following events and | ||
properties | properties | ||
<source lang="vdf"> | |||
pbCancelEdit | pbCancelEdit | ||
OnBeginLabelEdit | OnBeginLabelEdit | ||
OnEndLabelEdit | OnEndLabelEdit | ||
</source> | |||
These are documented in the Help system | These are documented in the Help system | ||
Line 59: | Line 69: | ||
====External references==== | ====External references==== | ||
[http://www.sture.dk/wasp/articledisplay.asp?RecId=181900 Automatic Edit item label in Treeview] | [http://www.sture.dk/wasp/articledisplay.asp?RecId=181900 Automatic Edit item label in Treeview] | ||
[http://www.sture.dk/wasp/articledisplay.asp?RecId=182179 Put label in Editmode immediately] | [http://www.sture.dk/wasp/articledisplay.asp?RecId=182179 Put label in Editmode immediately] | ||
[http://msdn.microsoft.com/en-us/library/bb773562(VS.85).aspx MSDN TVM_EDITLABEL Message] | [http://msdn.microsoft.com/en-us/library/bb773562(VS.85).aspx MSDN TVM_EDITLABEL Message] | ||
[[Category:How To]] | |||
[[Category:Tutorials]] |