以编程方式选择Listview的一行 [英] Select programmatically a row of a Listview

查看:71
本文介绍了以编程方式选择Listview的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在程序开始时选择列表视图的一行.

I don't get it to work to select a row of a listview 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;

致谢

推荐答案

set listView1.HideSelection=falselistView1.Focus()

这篇关于以编程方式选择Listview的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆