Solved

TREEVIEW: set focus to 1st node after populating

Posted on 2001-06-28
11
805 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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:
bhess1 earned 100 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:bhess1
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

778 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