gpt4 book ai didi

c# - 有没有办法单独设置 Winforms ListView 单元格的 BackColor?

转载 作者:行者123 更新时间:2023-11-30 13:27:30 25 4
gpt4 key购买 nike

我想使用不同的颜色为每个 ListView 单元格的 BackColor 着色。这可能吗?

最佳答案

要更改单元格的BackColor 颜色,您可以这样做:

listView1.Items[0].UseItemStyleForSubItems = false;
listView1.Items[0].SubItems[0].BackColor = Color.Green;
listView1.Items[0].SubItems[1].BackColor = Color.Orange;
listView1.Items[0].SubItems[2].BackColor = Color.Red;
// Change the 0 in Items[0] for whatever row you want,
// and the 0, 1 or 2 in SubItems[0] to whatever column you want.

第一行,

listView1.Items[0].UseItemStyleForSubItems = false;

将使单元格的行不都是相同的颜色。

这是演示图片:

enter image description here

希望这对您有所帮助!

关于c# - 有没有办法单独设置 Winforms ListView 单元格的 BackColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10958171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com