开发者

Showing current/selected item in ListView in WinForms

I have a ListView with about 400 entries. I need to search thru it for a value and when found I'm setting it to Selected and I would like ListView to somehow scroll to this item and show it on the screen.

How can I do this? Will setting .Focused do it?

        foreach (ListViewItem item in someListView.Items) {
            string varID = item.SubItems[0].Text;
            if (varID == someID) {
                item.Selected = true;
                item.BackColor = Color.Aquamarine;
                item.Focused = true;
                开发者_开发问答break;
            }
        }


Try using item.EnsureVisible();

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜