【发布时间】:2010-09-17 22:22:53
【问题描述】:
我在 C# 中使用 ListView 来制作网格。我想找到一种能够以编程方式突出显示特定单元格的方法。我只需要突出显示一个单元格。
我已经尝试使用所有者绘制的子项,但是使用下面的代码,我得到了突出显示的单元格,但没有文本!关于如何使它工作有什么想法吗?感谢您的帮助。
//m_PC.Location is the X,Y coordinates of the highlighted cell.
void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if ((e.ItemIndex == m_PC.Location.Y) && (e.Item.SubItems.IndexOf(e.SubItem) == m_PC.Location.X))
e.SubItem.BackColor = Color.Blue;
else
e.SubItem.BackColor = Color.White;
e.DrawBackground();
e.DrawText();
}
【问题讨论】:
标签: c# listview highlight ownerdrawn