Home All Groups Group Topic Archive Search About

Tree view node selection

Author
12 Apr 2006 12:20 AM
Adam Honek
Hi all,

How do we select a tree view's node outside of a tree view event?

Looking through the lists there's no select function, the nearest I can find
is GetNodeAt but this seems to want the screen coordinates.

Thanks,
Adam

Author
11 Apr 2006 11:51 PM
tommaso.gastaldi
with YourTreeview
    .SelectedNode = TheTreeNodeYouWishToSelect  ' (for instance:
..Nodes(0))
end with

Adam Honek ha scritto:

Show quoteHide quote
> Hi all,
>
> How do we select a tree view's node outside of a tree view event?
>
> Looking through the lists there's no select function, the nearest I can find
> is GetNodeAt but this seems to want the screen coordinates.
>
> Thanks,
> Adam
Author
12 Apr 2006 1:11 AM
Adam Honek
Your code works great.

The only problem is I have 3 nodes that all have an index of 0.

Worst still I can't change it in the properties. Strange.

I have:

X (0)
------X (0)
        ----- X (0)
        ----- X (1)
        ----- X (2)
        ----- X (3)

Adam

<tommaso.gasta***@uniroma1.it> wrote in message
Show quoteHide quote
news:1144799494.856085.275750@g10g2000cwb.googlegroups.com...
>
> with YourTreeview
>    .SelectedNode = TheTreeNodeYouWishToSelect  ' (for instance:
> .Nodes(0))
> end with
>
> Adam Honek ha scritto:
>
>> Hi all,
>>
>> How do we select a tree view's node outside of a tree view event?
>>
>> Looking through the lists there's no select function, the nearest I can
>> find
>> is GetNodeAt but this seems to want the screen coordinates.
>>
>> Thanks,
>> Adam
>
Author
12 Apr 2006 1:16 AM
Adam Honek
I also tried selecting it by its name but no go.

The node isn't highlighted for some reason.

Adam

Show quoteHide quote
"Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> wrote in message
news:OoE54WcXGHA.3492@TK2MSFTNGP05.phx.gbl...
> Your code works great.
>
> The only problem is I have 3 nodes that all have an index of 0.
>
> Worst still I can't change it in the properties. Strange.
>
> I have:
>
> X (0)
> ------X (0)
>        ----- X (0)
>        ----- X (1)
>        ----- X (2)
>        ----- X (3)
>
> Adam
>
> <tommaso.gasta***@uniroma1.it> wrote in message
> news:1144799494.856085.275750@g10g2000cwb.googlegroups.com...
>>
>> with YourTreeview
>>    .SelectedNode = TheTreeNodeYouWishToSelect  ' (for instance:
>> .Nodes(0))
>> end with
>>
>> Adam Honek ha scritto:
>>
>>> Hi all,
>>>
>>> How do we select a tree view's node outside of a tree view event?
>>>
>>> Looking through the lists there's no select function, the nearest I can
>>> find
>>> is GetNodeAt but this seems to want the screen coordinates.
>>>
>>> Thanks,
>>> Adam
>>
>
>
Author
12 Apr 2006 6:17 AM
Cor Ligthert [MVP]
Adam,

Be aware that this kind of code triggers the change events and can therefore
give some strange te first time not expected behaviour as you are not used
to that.

Just as little addition.

Cor

Show quoteHide quote
"Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht
news:efgiNZcXGHA.1352@TK2MSFTNGP05.phx.gbl...
>I also tried selecting it by its name but no go.
>
> The node isn't highlighted for some reason.
>
> Adam
>
> "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> wrote in message
> news:OoE54WcXGHA.3492@TK2MSFTNGP05.phx.gbl...
>> Your code works great.
>>
>> The only problem is I have 3 nodes that all have an index of 0.
>>
>> Worst still I can't change it in the properties. Strange.
>>
>> I have:
>>
>> X (0)
>> ------X (0)
>>        ----- X (0)
>>        ----- X (1)
>>        ----- X (2)
>>        ----- X (3)
>>
>> Adam
>>
>> <tommaso.gasta***@uniroma1.it> wrote in message
>> news:1144799494.856085.275750@g10g2000cwb.googlegroups.com...
>>>
>>> with YourTreeview
>>>    .SelectedNode = TheTreeNodeYouWishToSelect  ' (for instance:
>>> .Nodes(0))
>>> end with
>>>
>>> Adam Honek ha scritto:
>>>
>>>> Hi all,
>>>>
>>>> How do we select a tree view's node outside of a tree view event?
>>>>
>>>> Looking through the lists there's no select function, the nearest I can
>>>> find
>>>> is GetNodeAt but this seems to want the screen coordinates.
>>>>
>>>> Thanks,
>>>> Adam
>>>
>>
>>
>
>
Author
12 Apr 2006 7:37 AM
Klaus
Hi Adam,

you have more than one possibility :

    Private Sub TV_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles TV.MouseDown
          TV.actNode = TV.GetNodeAt(e.X, e.Y)
          TV.SelectedNode = TV.actNode
    End Sub

Direct methode (indexed) :
e.g.:
TV.SelectedNode = TV.nodes(0).nodes(0).nodes(2)
(assuming your example)

Klaus
Author
12 Apr 2006 10:48 PM
Adam Honek
Thanks a lot, got the code working once I added a TV.focus().

Adam

Show quoteHide quote
"Klaus" <k.bur***@chello.at> wrote in message
news:1144827458.833897.287870@e56g2000cwe.googlegroups.com...
> Hi Adam,
>
> you have more than one possibility :
>
>    Private Sub TV_MouseDown(ByVal sender As System.Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles TV.MouseDown
>          TV.actNode = TV.GetNodeAt(e.X, e.Y)
>          TV.SelectedNode = TV.actNode
>    End Sub
>
> Direct methode (indexed) :
> e.g.:
> TV.SelectedNode = TV.nodes(0).nodes(0).nodes(2)
> (assuming your example)
>
> Klaus
>
Author
12 Apr 2006 11:12 PM
Adam Honek
After selecting the given node, what tree view event does it fire?

KeyDown???

Adam

Show quoteHide quote
"Klaus" <k.bur***@chello.at> wrote in message
news:1144827458.833897.287870@e56g2000cwe.googlegroups.com...
> Hi Adam,
>
> you have more than one possibility :
>
>    Private Sub TV_MouseDown(ByVal sender As System.Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles TV.MouseDown
>          TV.actNode = TV.GetNodeAt(e.X, e.Y)
>          TV.SelectedNode = TV.actNode
>    End Sub
>
> Direct methode (indexed) :
> e.g.:
> TV.SelectedNode = TV.nodes(0).nodes(0).nodes(2)
> (assuming your example)
>
> Klaus
>