Trying to get a ListViewItem with a given value
Posted on 2006-07-02
I populated the ListView with driverLabel strings. And now I'd like to get the ListViewItem with a given matching string. But Items.IndexOf() return -1 even though I know it's been added. Am I missing anything obvious?
string driverLabel = driverRun.Driver.DriverLabel;
if ( driverLabel != null && driverLV.Items.Count > 0 )
int driverLabelIndex = driverLV.Items.IndexOf(new ListViewItem(driverLabel));
if ( driverLabelIndex > -1 && driverLabelIndex < driverLV.Items.Count )
driverRunsLV.Items[driverRunIndex].Selected = true;