有没有一种方法可以分别设置的WinForms ListView的细胞的背景色? [英] Is there a way to set the BackColor of Winforms ListView cells individually?

查看:135
本文介绍了有没有一种方法可以分别设置的WinForms ListView的细胞的背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用不同的颜色上色每个列表视图单元格的背景色。这可能吗?

I want to color each list view cell's BackColor using a different color. Is this possible?

推荐答案

要改变颜色的单元格的背景色,你可以这样做:

To change the colour of a cell's BackColor, you can do this:

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;

能做到使细胞的行是不是所有的彩色颜色相同。

Will make it so that the row of cells is not all coloured the same colour.

下面是一个演示画面:

希望这有助于!

这篇关于有没有一种方法可以分别设置的WinForms ListView的细胞的背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆