How to select an item in a ListView programmatically?

前端 未结 7 1511
野趣味
野趣味 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条回答
  •  旧时难觅i
    2020-12-08 09:42

    I think that the problem and the solution was descripted by cody gray! I've an additional note.

    Please check the focus of the specified listview item (and the control!). I could set the focus and the selection with the following lines of code :

    this.listView1.Items[1].Selected = true;
    this.listView1.Items[1].Focused = true;
    

    But the focused control was a condition!

提交回复
热议问题