Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoubleClick in a treeview

Status
Not open for further replies.

vikasb2

Programmer
Sep 8, 2003
19
0
0
IN
Hi

I want to have an event which fires only when user DoubleClicks a Node in Treeview.

Does any one knows about this - how to do this?

Thanks
Vikas

 
The DBLClick works when user double clicks on a blank area and not when a node.

Like NodeClick I want a NodeDblClick.

Scenario: I want to add a node item contents into some grid when user double clicks on a node in the tree view.

Vikas
 
The DBLClick works when user double clicks on a blank area and not when a node.

Actually, if you reference the node, the double click works. Put this code in the treeview dblclick event:
Code:
This.nodes.remove(This.SelectedItem.Key)
You could change it to do something else, but that is one example.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Vikas,

I think the reason the individual node object does not have a native double-click is because there is built-in behaviour for that event.

When you double-click on a node, you are telling the treeview that you want to expand the branch under the node.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks for the responses, but the problem is still there:

1:
If I use This.SelectedItem.Key in DblClick of the treeview, then suppose if user selected one node once and than DblClick on a empty area in the treeview control, I will still get the node value in This.SelectedItem.Key but actually the user has not dbl clicked on a node this time.

2:
DblClick expands the node, that is fine, but actually I need DblClick on leaf nodes where I want some custom action to happen as mentioned above.


 
Hi Vikas,

Before double click on node, identify user is double click on node or in the blank area. This is sample VB code to give a message when you DblClick on the node. It won't display any message when you click on the blank area-

1. Insert one TreeView and one command button in VB form.
2. Copy this code -

Dim NodeClick As Boolean
Private Sub Command1_Click()
TreeView1.Nodes.Add , , "Nd1", "Node1"
TreeView1.Nodes.Add "Nd1", tvwChild, "Nd2", "Node2"
NodeClick = False
End Sub
Private Sub TreeView1_DblClick()
If TreeView1.SelectedItem.Key = "Nd1" And NodeClick = True Then
MsgBox ("Select Node1 with Dblclick")
End If
If TreeView1.SelectedItem.Key = "Nd2" And NodeClick = True Then
MsgBox ("Select Node2 with Dblclick")
End If
NodeClick = False
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
NodeClick = True
End Sub

Convert this code in VFP. Hope this will solve your problem.

Thanks,
Pankaj

Senior Software Engineer,
Infotech Enterprises Limited
Hyderabad, Andhra Pradesh, India.
URL :
 
Hi Pankaj

Thanks for the solution. This will solve our problem. Actually we have now switched to treeview instead of ksoutline (in cQOS/vizKat) and hence the question.

Actually I had the solution which uses _DBLCLICK and
seconds() for this - but I was looking for a more elegant solution - which I got now.

Cool!

Thanks all of you.

Just for forum's info - Pankaj and I used to work in the same company earlier - that's why I talked some old things also here.

Vikas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top