【发布时间】:2011-11-02 12:29:12
【问题描述】:
我有一个很长的 ListView,其中包含我的应用当前正在运行的操作列表(一次每个操作)。 在运行每个操作时,相关的 ListViewItem 会以粗体显示。 ListView 很长,所以我有垂直滚动条。
我的问题是如何向用户显示当前正在运行的操作,这意味着我如何将列表视图“滚动”到该项目。
我尝试手动选择行 ==> 不起作用。 我使用了 ListViewItem.EnsureVisible 但这使得 ListView 在每次更改时都会闪烁。
有什么想法吗?谢谢。
已编辑:我添加了一些代码,尽管代码非常简单。 每当运行新操作时,我都会运行以下命令:
foreach (ListViewItem item in m_ListView.Items)
{
FontStyle style = ((index == value) ? FontStyle.Bold : FontStyle.Regular);
item.Font = new Font(item.Font, style);
if (index == value)
{
m_ModulesListView.EnsureVisible(index);
}
index++;
}
【问题讨论】:
-
嗨,请显示一些代码,尤其是您调用 EnsureVisible 的方式...这应该是首选解决方案,关于闪烁它可能取决于您调用它的方式以及您对控件的操作。