Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Scrollin a TreeView


Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2003, 10:14 AM
NeoGioZ's Avatar
NeoGioZ NeoGioZ is offline
Centurion
 
Join Date: Oct 2001
Location: Florida
Posts: 115
Lightbulb Scrollin a TreeView


I have a TreeView control that will refresh it self every 30 seconds. The problem is that after the user has scrolled, say, half way down the TreeView and the TreeView refreshes (i.e. TreeView.Nodes.Clear and repopulate) the TreeView goes back to the top. I know how to keep the same structure that the user was looking at and record the top Node being displayed at the time. What I don't know how to do is make the TreeView scroll down. I thought about using the SendMessage API to tell the tree view to scroll down and keep testing the top noded but I think that could get a little messy. Any ideas?

Thanks in Advance
__________________
NeoGioZ

"I wish I was a neutron bomb, for once I could go off" -- Pearl Jam
Reply With Quote
  #2  
Old 05-23-2003, 10:48 AM
DrPunk's Avatar
DrPunk DrPunk is online now
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,272
Default

You should be able to call the EnsureVisible method of the selected node.

Code:
Treeview1.SelectedItem.EnsureVisible ' Or to be really careful If Not Treeview1.SelectedItem is Nothing Then Treeview1.SelectedItem.EnsureVisible End if
Reply With Quote
  #3  
Old 05-23-2003, 12:03 PM
NeoGioZ's Avatar
NeoGioZ NeoGioZ is offline
Centurion
 
Join Date: Oct 2001
Location: Florida
Posts: 115
Default EnsureVisible

Thanks for your reply.

EnsureVisible will not work because all it does is make sure that if the Current Node is a child that it will expand all the necesary parents to ensure that the Current Node is visisble.
__________________
NeoGioZ

"I wish I was a neutron bomb, for once I could go off" -- Pearl Jam
Reply With Quote
  #4  
Old 05-23-2003, 12:28 PM
DrPunk's Avatar
DrPunk DrPunk is online now
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,272
Default

Quote:
Originally Posted by NeoGioZ
Thanks for your reply.

EnsureVisible will not work because all it does is make sure that if the Current Node is a child that it will expand all the necesary parents to ensure that the Current Node is visisble.


Are you sure?

This code works on my PC, in that it adds 100 children to a root, and makes sure child66 is visible in the list. Make the treeview tiny.

Code:
Dim i As Long TreeView.Nodes.Clear TreeView1.Nodes.Add , , "Top", "Top" For i = 1 To 100 TreeView1.Nodes.Add "Top", tvwChild, "Child" & i, "Child" & i Next TreeView1.Nodes("Child66").Selected = True TreeView1.SelectedItem.EnsureVisible TreeView1.SetFocus

If it really doesn't work for you then what release of the Windows Common Controls are you using? It should have a "(SP?)" after the name of the component.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hooking or Subclassing a Treeview? LiquidPenguin General 4 04-24-2003 11:41 AM
Treeview and Imagelist, I'm completely lost Antoine General 12 03-31-2003 01:03 PM
TreeView Help Needed oceanic99 General 4 03-17-2003 09:28 AM
TreeView Subclassing cpukiller Interface and Graphics 14 11-06-2002 07:26 AM
TreeView - want to highlight part of treeView mattrade General 4 09-09-2002 03:04 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->