I'm having a lot of trouble with the "Selected" method, which is supposed to
select the required node by highlighting it. Most of the time it doesn't
actually highlight the node, but does in fact consider it to be selected
(which can be tested by using the SelectItem property).
Does anyone know how to get the control to (always) highlight the node when
it is being selected from code?
Thanks,
Vilem Sova
Canberra, Australia
Ron Weiner - 13 Jan 2005 03:31 GMT
To select a node program magically all you need to do is to first select it
then ensure it is visible. So if I wanted to select node 3 whose Key was
Position3 I'd :
tvwFiles.Nodes("Position3").Selected = True
tvwFiles.Nodes("Position3").EnsureVisible
If the node was a parent and I wanted to expand it (to show the children)
I'd:
tvwFiles.Nodes("Position3").Expanded = True
tvwFiles.Nodes("Position3").Selected = True
tvwFiles.Nodes("Position3").EnsureVisible
Ron W
> I'm having a lot of trouble with the "Selected" method, which is supposed to
> select the required node by highlighting it. Most of the time it doesn't
[quoted text clipped - 7 lines]
> Vilem Sova
> Canberra, Australia
Vilem Sova - 13 Jan 2005 05:39 GMT
Yes, I've tried exactly this combination of methods and a few other things
that I could think of, but although the treeview control is selecting the
node, the node is not appearing highlighted to the user (it does in some
rare instances but generally not).
This is why I'm asking if this is a known bug in the control and if anyone
has a workaround.
Thanks for your response,
Vilem Sova
> To select a node program magically all you need to do is to first select it
> then ensure it is visible. So if I wanted to select node 3 whose Key was
[quoted text clipped - 25 lines]
> > Vilem Sova
> > Canberra, Australia
Ron Weiner - 13 Jan 2005 12:11 GMT
Vilem
You might also want to make sure the treeview has the focus. If all of this
selection stuff takes place from a click event of another control on the
form that tree view will not have the focus. Soooo.... Try
tvwYourControl.SetFocus
After all of the other stuff you are doing.
Ron W
> Yes, I've tried exactly this combination of methods and a few other things
> that I could think of, but although the treeview control is selecting the
[quoted text clipped - 38 lines]
> > > Vilem Sova
> > > Canberra, Australia
Alex Dybenko - 13 Jan 2005 08:50 GMT
Hi Vilem,
also check that hideselection property is set to false (i think it is true
by default)

Signature
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com
> I'm having a lot of trouble with the "Selected" method, which is supposed
> to
[quoted text clipped - 9 lines]
> Vilem Sova
> Canberra, Australia
Vilem Sova - 14 Jan 2005 01:19 GMT
Thanks Ron & Alex for your responses.
I tried Alex's suggestion first, which did highlight the node, but not in
the same color as when the user clicks onto the node.
Applying the SetFocus method first did the trick though, highlighting the
node in the right color.
Thanks again,
Vilem
> I'm having a lot of trouble with the "Selected" method, which is supposed to
> select the required node by highlighting it. Most of the time it doesn't
[quoted text clipped - 7 lines]
> Vilem Sova
> Canberra, Australia