Programmatically edit a treeview label: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
m
Added to Tutorials category
m (Added to Tutorials category)
 
(7 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:


Then you have to send WM_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
     Send Windows_Message TVM_EDITLABEL 0 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 OnClick
<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 63: Line 73:


[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]]

Navigation menu