简体   繁体   English

列表视图子项前景色

[英]Listview Subitems Forecolor

How to change forecolor for all subitems in listview .如何更改listview中所有子项的forecolor

I have 2 columns, I need column 1 white, and second (subitems) column gray color.我有 2 列,我需要第 1 列白色,第二(子项)列灰色。

tried this after setting gray color from items & subitems UI,在从项目和子项目 UI 设置灰色后尝试此操作,

listView1.Items[0].UseItemStyleForSubItems = false;

but not working for items[1] .但不适用于items[1]

Any solutions?有什么解决办法吗?

Thanks谢谢

I have checked that code.我已经检查了该代码。 It is working.这是工作。 I think it will work for you too.我想它也对你有用。 A detail discussion is available in the given link.给定链接中提供了详细讨论。 Thank you.谢谢你。

for (int i = 0; i < listView1.Items.Count; i++)
{
   listView1.Items[i].UseItemStyleForSubItems = false;
   listView1.Items[i].SubItems[0].ForeColor = System.Drawing.Color.White;
   listView1.Items[i].SubItems[1].ForeColor = System.Drawing.Color.Gray;
}

Addional Information: There is a very similar question is available on that link.附加信息:该链接上有一个非常相似的问题。 Please check the provided link: How can I change the ForeColor of a single sub item in a ListView control?请检查提供的链接: 如何更改 ListView 控件中单个子项的前景色?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM