treeview - selected items

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 ???????
LVL 10
smeggheadAsked:
Who is Participating?
 
jgvConnect With a Mentor Commented:
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

0
 
smeggheadAuthor Commented:
I think I tried every combination of...

if isnull(expr)
if expr=nothing

etc..

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

Smeggy
0
All Courses

From novice to tech pro — start learning today.