C# ListView Detail, Highlight a single cell

后端 未结 3 1765
既然无缘
既然无缘 2021-01-02 04:45

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.

3条回答
  •  太阳男子
    2021-01-02 05:31

    Figured it out. Here's code to toggle the highlight of a specific subitem.

    listView1.Items[1].UseItemStyleForSubItems = false;
    if (listView1.Items[1].SubItems[10].BackColor == Color.DarkBlue)
    {
        listView1.Items[1].SubItems[10].BackColor = Color.White;
        listView1.Items[1].SubItems[10].ForeColor = Color.Black;
    }
    else
    {
        listView1.Items[1].SubItems[10].BackColor = Color.DarkBlue;
        listView1.Items[1].SubItems[10].ForeColor = Color.White;
    }
    

提交回复
热议问题