Programmatically selecting a listview item..??

V

vince

I need to programmatically select the first item in a
listview before the listview is displayed, so far I'm not
having any luck. Here's what I tried in the init for the
listview...

LoadListView();
listView4.Items[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a
difference...

Thanks for any help.

Vince
 
N

Norm Yuan

If you code is correct, I am sure it IS selected. But to visibly show the
selection, the listview must have focus ( add listView4.Focus() following
listView4.Items[0].Selected=true), or ListView.HideSelection property is set
to false (default value is true).
 
V

vince

thanks, that was it, needed to set focus in addition to
selecting...

-----Original Message-----
If you code is correct, I am sure it IS selected. But to visibly show the
selection, the listview must have focus ( add listView4.Focus() following
listView4.Items[0].Selected=true), or
ListView.HideSelection property is set
to false (default value is true).

vince said:
I need to programmatically select the first item in a
listview before the listview is displayed, so far I'm not
having any luck. Here's what I tried in the init for the
listview...

LoadListView();
listView4.Items[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a
difference...

Thanks for any help.

Vince


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top