Wednesday, March 28, 2012

Programmatically Select a listview item

Can't seem to figure out how to do this. The listview class browser doesn't list much in the way of an API call to do this. Anyone know if this is possible?Did you figure this out?

ListView.SelectedListViewItemCollection listViewItemCollection = this.ListView1.SelectedItems;

foreach ( ListViewItem item in listViewItemCollection)
{
//Your code goes here
}


ListView1.Items(0).Selected = True
ListView1.Select()

The first line indicates what item is to be selected, and the second line is what actually selects it. The most common mistake is leaving out the second line.

No comments:

Post a Comment