我在C#中使用ListView來製作一個網格。我想通過編程的方式找到一種能夠突出特定單元格的方法。我只需要突出顯示一個單元格。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();
}
Winforms or web? – tvanfosson 2008-10-18 17:02:38