Programmatically selecting a listview item..??

  • Thread starter Thread starter vince
  • Start date Start date
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
 
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).
 
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


.
 
Back
Top