ListViews Setting the selected Item How???

  • Thread starter Thread starter StriderBob
  • Start date Start date
S

StriderBob

In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all
work fine but how do you set the selected line in a ListView, is it
possible?

The ListView is being used in Details-View mode, in each line the first item
is a line No. (1 - 150 in this instance). I can get an index no for a line I
select with the mouse but cannot find a way to programatically select a line
(Specifically, for example, either select item 10 or ListView index 9).

Also In association with this I need to be able to use the up and down
keyboard arrows to move the selected line up and down. I assume the answer
to the first part will answer the second part but is there yet another twist
I need to know??

Bob
 
In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all
work fine but how do you set the selected line in a ListView, is it
possible?

The ListView is being used in Details-View mode, in each line the first item
is a line No. (1 - 150 in this instance). I can get an index no for a line I
select with the mouse but cannot find a way to programatically select a line
(Specifically, for example, either select item 10 or ListView index 9).

Also In association with this I need to be able to use the up and down
keyboard arrows to move the selected line up and down. I assume the answer
to the first part will answer the second part but is there yet another twist
I need to know??

Hi Bob,

try listview.Items(index).Selected = True

Steve
 
Steve Cutting said:
Hi Bob,

try listview.Items(index).Selected = True

Steve

Thanks Steve, I think !!

Your suggestion works fine in my small test program but when I copy the
whole contents to the child form in my main program it does not. I can see
several days of wonderful MS inspired fun ahead finding out what is the next
question I will need an answer to.

By the way, I cannot find any reference to your solution in the help index
for ListViews. Awesome!!

Bob
 
Back
Top