Forum Discussion
What are you clicking on?
The first example I linked to, the expanders (the bit you need to click on) was a child object of the node.
The second example was a little more fiddly. You can still find the node using content text, but it's the little arrow on the left you need to click to expand it. This is not seen as a child object like in the first example. But instead, you just click half way up the height of the node and a couple of pixels in from the left and it expands as it's supposed to.
If your one uses clicks on the node directly (rather than an embedded child object), then you need to do something similar to the first reply. ie. get the co-ordinates of the node, work out the centre-point, and just apply a mouse click there. Similar to the second example. If it's the "+" in a box you need to click, get the left edge and centre point of the node , relative to the control container, and then move left a set number of pixels and that should click on the expander.
There will be a way of doing it. Might just need a little more thought than usual. All the elements seem to be there. You just need to work out a way of manipulating it if it's not giving you out-of-the-box methods you can use. Not all controls do. Another possibility may be to use keypresses to move around inside it. Depends if the active node is flagged in a way that you can detect. eg. Move down all nodes in a loop checking which one is active each time. When the one you want becomes active, hit enter, or space, or whatever key acts as a shortcut in your case.
Your second screenshot isn't very helpful without some context. I have no idea where that control sits. Is it a node? Is it a child of a node? Where does the top level container sit? And there are a bunch more properties cut off and we can't see any of the available methods ....
I need to expand the list and select one child object.
First I need to click on the "Routine" in the TreeView (attached Imange TreeView1.PNG) which will be expanded then I have to click on its child object "Field Notes" and then "national bridge Inventroy" and then select the last child item,(attached Image FullTreeView.PNG)
In this treeView Only the '+' sign in clickable
My goal is to select the last child item.
I tried using the Space click but its just refreshing the object.Trying for the coordinates.
- Colin_McCrae9 years agoCommunity Hero
OK. Sounds much the same as my second example.
So assign the tree container (the top level object - the tree itself) to a variable.
Do a FindChild on that using the content text to get the node you want.
Then get the Height property of the node. You don't need the width as you will always apply the click at the same point in from the left. Apply a click to the found node using half the height as the Y co-ordinate, and 4 (or whatever is applicable, I don't know the exact size and scaling here) as the X co-ordinate. This should apply the click on the "+" and expand the node.
Obviously, you'll probably need to put this in some sort of loop if you need to go several levels deep. I can see how it could be done, but I'm afraid I can't sit here at work and write an entire custom routine for you!
I have to do something very similar to this on a Tree View in my application as there are custom event triggers on it which are only triggered if the mouse click is applied in the correct place. So I do the same thing. Find the node, then use it's size and relative position to the parent control to work out where to apply the click.