treeview nodeclick |
Post Reply |
Author | ||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
Posted: 29 December 2010 at 2:11pm |
|
I hope that I am missing something... i am using the treeview control in conjunction with the docking pane. When the user clicks a node on the treeview a new pane is added and displayed in the docking pane manager. If the user then clicks the close form button on the docking pane the pane is destroyed and the tree node.expanded is set to false. The problem is that if the user clicks the same tree node again the nodeclick event is not fired. I have tried setting the .selecteditem property equal to nothing bnut that does not help. How can I get the node click event to fire when the same/selected node is clicked a second time?
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
According the the help file, that is the expected behaviour of the NodeClick event:
Here's a possible work-around (haven't tested it fully, so please test before deploying):
|
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
Thanks JPBro... yes, I saw from the documentation that that was the expected behaviour. I'll try the code you posted to see if that works for me. On a related issued I notice that when I click a node (other than the first node) that the nodeclick event fires twice... once for the first node on the tree and a second time for the node that I click. I see that this is also the "expected" behaviour but it makes no sense to me that the control works likes that. I saw a suggestion in another thread on this same issue that suggested using a "dummy" node as the first node but this really does not solve the problem as, from what I can tell, there is no way to make a node invisible. Any (better) idea about how to deal with this issue?
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
I haven't been able to reproduce the problem of the NodeClick event firing for the first item when you click a second item, do you have a sample project that demonstrates this?
One thing I have seen is that the NodeClick property fires for the first item when you start the program (even though the user hasn't clicked anything yet). If this is a problem, you can prevent it like this:
|
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
Yes, I have the same problem with the node_click event firing when the form is first loaded.
Here is a post from AAron that deals with the other issue I posted:
I'll have to say that I'm really dissapointed in the behavior of the TreeView control. These couple of issues and the related work arounds are very frustrating... I may be forced to go back to the standard MS TreeView control as I did not have these problems. Any idea if these have been address in a newer release? I am currently on 13.2.1.
Thanks again for your feedback
|
||
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
|
Hi,
That's the reason I stick with MS controls. I once asked a list of differences between MS and CJ controls but never got a reply. I really would like to use the CJ controls but I don't want to wait for some "strange" behavior to occure and don't have a solution. I prefer one library but it's to risky...
Good luck
|
||
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
Glad to help - I'm not sure if anything has changed with the TreeView in the latest versions (I don't actually use it for anything myself). If you open a support ticket with CodeJock at https://support.codejock.com then you might be able to get your issues resolved.
In the meantime, I've put together a little re-usable class that will fire it's own NodeClicked event as follows: 1) NOT at application start 2) Anytime a Node is clicked (even if it was previously selected). I haven't been able to get it to fire erroneously yet, but I've only tested it for the most obvious use cases - your project may present scenarios that cause it to behave undesirably. Here's the demo: uploads/2676/TreeViewNodeClickMod.zip |
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
|
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
Thanks jpbro... I'll have a look at your code.
|
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
jpbro, thanks again for the code... it seems to have resolved the issues that I originally found. Now, it seems that there is one last issue that I can't seem to figure out. When I click a node for the first time i set the nodes expanded property = true. The next time I click the node, the program should see that the node was expanded and perform some different action from the first time the node was clicked (e.g., close a docking pane). For some reason, the expanded property for the node is always equal to false... any ideas on this would be greatly appreciated.
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
I've tried getting the Expanded property to report its value incorrectly without luck. Maybe it was fixed?
If you could modify my sample and provide steps to demonstrate the problem, I will try it here and see if the problem still exists (and if so, see if I can find a workaround). |
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
Thanks, let me play with it some more over the weekend before tying up more of your time. Have a happy and safe New Year!
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
Sure thing - and a safe and happy new year to you too!
|
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
Okay, I update my controls to 13.4.2 (I was on 13.2.1) and still cannot seem to get the expanded property to work. Here is the change that I made to your code:
Private Sub mo_NodeClickMod_NodeClicked(Node As XtremeSuiteControls.TreeViewNode) ' Instead of using the forms TreeView1_NodeClicked event, ' We use our modified handlers NodeClicked event ' The modified handlers NodeClick event doesn't fire on startup, ' and fires even if the already selected node is clicked again. Debug.Print "NODE CLICKED: " & Node.Text & ", Index: " & Node.Index & " @ " & Timer & " " & Node.Expanded Node.Expanded = Not (Node.Expanded) End Sub The Node.Expanded property is always shown as false everytime I click a node. Is it possible that the expanded property does not "work" if there are no child nodes?
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
Strange - I'm not sure what is going on on your end.
I used your code and added a Debug.Print "Expanded: " & Node.Expanded line, and when I click the parent node a few times, it expands and shrinks as expected for me* Here's my debug output:
* I notice that when double-clicking the parent node, it expands and shrinks, so each click in the double-click is counted. I will have to come up with a workaround for this. |
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
That's strange... I had added the node.expanded value to the end of the existing debug statement and was seeing the expanded value always equal to false. I did find that if I added a child node to the 'Test' node that the expanded property was changing each time I clicked the 'Test' node. I do not think that I made any changes to your sample project... were nodes 'Test2' - 'Test4' child nodes in your sample (they are parent nodes, without children in the sample code that I have)?
|
||
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
|
Okay, I think I see where I misunderstood now - the Expanded property is working for you when a Node has Child Nodes, but not if the Node has no child nodes.
The documentation doesn't mention whether or not this is the expected behaviour, but to me it makes sense - How can a Node be expanded when there is nothing under it to expand? Nodes also don't show the +/- icon when there are no children, so there is no visual confusion either. You have a couple of other options though - if you aren't using Checkboxes in your TreeView, you could substitute the Node.Checked property for the Node.Expanded property. Alternately, if you aren't using the Node.Tag property, you could use it for the same purpose. |
||
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
||
johnp
Groupie Joined: 21 February 2008 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
|
I understand the logic of what you're saying but, I believe that the behaviour of the MS treeview is different (i.e., expanded can equal true even when no child nodes exist). I appreciate your time on this and will rewrite my code so that it works without using the expanded property.
|
||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |