How to select an item in a ListView programmatically?

前端 未结 7 1508
野趣味
野趣味 2020-12-08 09:13

I\'m trying to select the first item in a ListView programmatically, but it doesn\'t appear to have been selected. I am using the following code:

if (listVie         


        
7条回答
  •  醉酒成梦
    2020-12-08 09:38

            int i=99;//is what row you want to select and focus
            listViewRamos.FocusedItem = listViewRamos.Items[0];
            listViewRamos.Items[i].Selected = true;
            listViewRamos.Select();
            listViewRamos.EnsureVisible(i);//This is the trick
    

提交回复
热议问题