C# ListView Detail, Highlight a single cell

Posted by Mike Christiansen on Stack Overflow See other posts from Stack Overflow or by Mike Christiansen
Published on 2008-10-18T16:43:03Z Indexed on 2010/03/21 17:01 UTC
Read the original article Hit count: 784

Filed under:
|
|
|

Hello,

I'm using a ListView in C# to make a grid. I would like to find out a way to be able to highlight a specific cell, programatically. I only need to highlight one cell.

I've experimented with Owner Drawn subitems, but using the below code, I get highlighted cells, but no text! Are there any ideas on how to get this working? Thanks for your help.

//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();
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about listview