改变颜色的ListView列项 [英] Change color to Listview column item

查看:136
本文介绍了改变颜色的ListView列项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能改变特定列一个特定项目的颜色列表视图

Is it possible to change color of a specific item for specific column in Listview ?

推荐答案

给定一个的ListView 名为 ListView1的

如果你知道你想改变列的名称,那么试试这个:

If you know the name of the column you want to change, then try this:

foreach(ListViewItem theItem in ListView1)
{
    if(theItem.Text == "Column Name")
    {
        theItem.ForeColor = Color.Red;

        // You also have access to the list view's SubItems collection
        theItem.SubItems[0].ForeColor = Color.Blue;
    }
}

注:显然栏目名称是由,你会需要替代真正的列名。此外, Col​​or.Red 是由你可以代替任何你想要的颜色。

Note: Obviously Column Name is made up and you would need to substitute the real column name. Also, Color.Red is made up and you can substitute whatever color you want.

这篇关于改变颜色的ListView列项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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