treeview - selected items

Posted on 1999-07-20
Medium Priority
Last Modified: 2008-03-10
how can I determine if there are any items selected in a treeview control ??

the equivalent of lstBOX.listindex=-1 (in a standard listbox)

I'm currently using an error trap...

dim pos%
on error resume next
set pos=lstPEOPLE.SelectedItem.index
if err<>0 then ....

I'm not too keen on error traps, except when absolutely necessary.

I also want to avoid this..

for each nod in lstPEOPLE.NODES
 if nod.selected=true then ....
next nod

I also want a quick and easy way of un-selecting all items in a treeview

Any ideas anyone ???????
Question by:smegghead
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Accepted Solution

jgv earned 200 total points
ID: 1526095
To check if an item is selected and assign the index to a variable ('x'):

Dim x

If Not (TreeView1.SelectedItem Is Nothing) Then
    x = TreeView1.SelectedItem.Index
End If

To unselect a selected item (only one item can be selected at any given time in a treeview):
Set TreeView1.SelectedItem = Nothing

LVL 10

Author Comment

ID: 1526096
I think I tried every combination of...

if isnull(expr)
if expr=nothing


but not that one, thanks.........


Featured Post

Independent Software Vendors: 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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

718 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