Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TREEVIEW: set focus to 1st node after populating

Posted on 2001-06-28
11
Medium Priority
?
893 Views
Last Modified: 2006-11-17
hello-

this is a stupid question, but for some reason, when i populate my treeview from database entries, the treeview scrolls to the bottom.

basically, the top item(1st node) is not visible, unless you manually scroll back up.

Q: how do keep the focus on the first node, so it is visible after populating the treeview.
0
Comment
Question by:jas777
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 2

Expert Comment

by:agriggs
ID: 6234802
Try: Treeview.Nodes(1).EnsureVisible after you have loaded the treeview.
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6234804
The treeview will scroll as it is loaded, nothing you can do about that, but you can set the first item as the selected item after the load completes, to resync the view
0
 

Expert Comment

by:jsopher
ID: 6234836
dave-

   can you give me the syntax
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:jsopher
ID: 6234841
jas777

i think you should try and extend the length of the treeview
0
 

Author Comment

by:jas777
ID: 6234855
i tried agriggs comment, and was unnsuccessful.

basically, my treeview is a certain size, and because after populating, the items in the treeview, require a longer treeview, the scrolling automatically occurs.

if you guys have an EXAMPLE of setting the selected item as the first node, i would really appreciate it.
0
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 400 total points
ID: 6234928
Do you have a root item in your Treeview that all other items depend on?  Then you should be able to specify that node using the EnsureVisible property:

tvwMine.Nodes("Root").EnsureVisible

Do this after sorting the Treeview (if you sort it)

You could also insert the data into the Treeview in Reverse order (bottom to top).  Thus, the last entered item would be the one on top.
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 6234934
Note - you also use EnsureVisible only after the Treeview is fully populated.
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6234950
For i = 0 To 100
    Set nodX = TreeView1.Nodes.Add(1, tvwChild)
    nodX.Text = List1.List(i)
Next i

Treeview1.Nodes(1).Selected = True
nodX.EnsureVisible     ' Make sure the node is visible.
0
 

Author Comment

by:jas777
ID: 6235019
thanks dude, you rule
0
 
LVL 2

Expert Comment

by:agriggs
ID: 6236087
I am just curious why

tvwMine.Nodes("Root").EnsureVisible

works and

Treeview.Nodes(1).EnsureVisible

doesn't?  Ok, I give.
0
 

Author Comment

by:jas777
ID: 6236357
agriggs, i apologize, but i didn't implement yours correctly.  i used the index as 0, not 1 - as you reccommeded.

let me know how i can award you some points at least, and i will.

if you want me to post a "dummy" question just for you, let me know.

sorry man, my brain is on cloud 9
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question