Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Selecting an item in Treeview control, without knowing its index.


Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2003, 04:45 PM
Commodore Commodore is offline
Freshman
 
Join Date: Nov 2002
Posts: 34
Default Selecting an item in Treeview control, without knowing its index.


How would you accomplish this?

I have a treeview control and a listview control.. I render files and folders from the harddrive, the problem is when I put the folders/subfolders in the listview control, and the user doubleclicks on it, I want the treeview control to automaticly select the folder/subfolder.

The best would be if you could set the selecteditem of the treeview control to a certain key value, instead of the index value.

A way to accomplish what I want would be to use a FOR-loop:
For i = 1 to treeview.nodes.count
if treeview.nodes.item(i).key = sKey then
set treeview.selecteditem = treeview.nodes.items(i)
next i

but wouldn´t this be very slow when there are maybee 5000 items in the treeview control?

Any suggestions?
Thanks.
Reply With Quote
  #2  
Old 08-02-2003, 12:30 PM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

There is no reason why you can't say...
Set treeview1.SelectedItem = treeview1.Nodes.Item(sKey)
__________________
Posting Guidelines
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
multi connections, one port? burningodzilla Communications 5 08-02-2005 05:04 PM
hide/show a form's border in run time with api setwindowlong wolfmanzeev API 4 04-08-2003 04:10 AM
A nicer way to move a borderless form Merrion Code Library 2 07-18-2002 08:40 AM
control array okiegrl General 9 07-13-2001 02:48 PM
Control Arrays: What, Why and How BillSoo Tutors' Corner 0 07-13-2001 12:46 PM

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
 
 
-->