开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜