Scroll treeview in code

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

Is it possible to scroll the nodes visible in a treeview in code? I want to
move a node that has been selected in a search by code, make it the
SelectedNode, and position it as the top visible node in the treeview after
selection by code.

Thanks,
Dean Slindee
 
Hi Dean,

You needn't scroll the TreeView manually. When you select the node by using
SelectedNode property, the TreeView will automatically scroll to that node
and make it as the top visible node in the view. All you need to do is to
assign the node the the SelectedNode.

HTH

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Dean Slindee" <[email protected]>
| Subject: Scroll treeview in code
| Date: Sun, 28 Sep 2003 23:13:11 -0500
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 0-1pool36-245.nas14.milwaukee1.wi.us.da.qwest.net
63.156.36.245
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142067
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Is it possible to scroll the nodes visible in a treeview in code? I want
to
| move a node that has been selected in a search by code, make it the
| SelectedNode, and position it as the top visible node in the treeview
after
| selection by code.
|
| Thanks,
| Dean Slindee
|
|
|
|
 
This is an application that is like a telephone book. The treeview
initially has only the letters "A" thru "Z" showing. There is a textbox
above the treeview that allows the user to key in a lastname, firstname.
When the first letter is keyed in, the children for that letter are loaded
and the letter is expanded to show all the children. What I would like to do
is roll the child nodes up as the user types in the second character of the
name to show the first child node (and all others below it) also with those
two characters. I don't want to select that node, because selecting it
would fire the node_AfterSelect event which would load a listview just to
the right of the treeview. I only want to fire the load of the listview
when there is only one name in the database that matches however many
characters have been typed into the textbox.
Firing the node_AfterSelect event on a partial match would result in too
much activity going on in the listview. But, scrolling the treeview up to
match the textbox characters would be very helpful. Any suggestions for
just scrolling the treeview?
 
Hi Dean,

According to my knowledge, TreeView does not provide such a mothod for you
to scroll it in your own code. Scrollings are encapsuled in the TreeView
Class. I think you can set a flag in your code for the AfterSelect event to
identify whether the Select is from the user or your code. This might be a
workaround.

HTH

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Dean Slindee" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Scroll treeview in code
| Date: Mon, 29 Sep 2003 22:50:00 -0500
| Lines: 70
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 0-1pool37-18.nas14.milwaukee1.wi.us.da.qwest.net
63.156.37.18
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142416
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| This is an application that is like a telephone book. The treeview
| initially has only the letters "A" thru "Z" showing. There is a textbox
| above the treeview that allows the user to key in a lastname, firstname.
| When the first letter is keyed in, the children for that letter are loaded
| and the letter is expanded to show all the children. What I would like to
do
| is roll the child nodes up as the user types in the second character of
the
| name to show the first child node (and all others below it) also with
those
| two characters. I don't want to select that node, because selecting it
| would fire the node_AfterSelect event which would load a listview just to
| the right of the treeview. I only want to fire the load of the listview
| when there is only one name in the database that matches however many
| characters have been typed into the textbox.
| Firing the node_AfterSelect event on a partial match would result in too
| much activity going on in the listview. But, scrolling the treeview up to
| match the textbox characters would be very helpful. Any suggestions for
| just scrolling the treeview?
|
| | > Hi Dean,
| >
| > You needn't scroll the TreeView manually. When you select the node by
| using
| > SelectedNode property, the TreeView will automatically scroll to that
node
| > and make it as the top visible node in the view. All you need to do is
to
| > assign the node the the SelectedNode.
| >
| > HTH
| >
| > If anything is unclear, please feel free to reply to the post.
| >
| > Kevin Yu
| > =======
| > "This posting is provided "AS IS" with no warranties, and confers no
| > rights."
| >
| > --------------------
| > | From: "Dean Slindee" <[email protected]>
| > | Subject: Scroll treeview in code
| > | Date: Sun, 28 Sep 2003 23:13:11 -0500
| > | Lines: 10
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.vb
| > | NNTP-Posting-Host: 0-1pool36-245.nas14.milwaukee1.wi.us.da.qwest.net
| > 63.156.36.245
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142067
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | Is it possible to scroll the nodes visible in a treeview in code? I
| want
| > to
| > | move a node that has been selected in a search by code, make it the
| > | SelectedNode, and position it as the top visible node in the treeview
| > after
| > | selection by code.
| > |
| > | Thanks,
| > | Dean Slindee
| > |
| > |
| > |
| > |
| >
|
|
|
 
I use the following code in my treeView class to horizontal-scroll the
treeView to the mostLeft.
I guess you can change the parameters to your needs:

Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As
IntPtr, _
ByVal msg As Integer, ByVal wParam As Integer, ByVal
lParam As Integer) As IntPtr

Dim WM_HSCROLL As Integer = &H114
Dim SB_LEFT As Integer = 6
SendMessage(Me.Handle, WM_HSCROLL, SB_LEFT, 0)

Atara.
 
Back
Top