Select programmatically a row of a Listview
I don't get it to work to select a row of a listvi开发者_高级运维ew at the beginning of my program.
if (listView1.Items.Count > 0)
{
listView1.Items[0].Selected = true;
listView1.Items[0].Focused = true;
}
After running this snippet the first item is selected and focused.
listView1.Items[0].Selected
true
listView1.Items[0].Focused
true
after clicking manually an item in the listview I can walk thru this list with
listView1.Items[newPosition].Selected = true;
regards
set listView1.HideSelection=false
and listView1.Focus()
精彩评论