How to select an item in a ListView programmatically?

前端 未结 7 1492
野趣味
野趣味 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:51
    if (listView1.Items.Count > 0)
    {
        listView1.Items[0].Selected = true;
        listView1.Select();
    }
    

    list items do not appear selected unless the control has the focus (or you set the HideSelection property to false)

    0 讨论(0)
提交回复
热议问题