Listview项目颜色问题 [英] Listview item color question

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

问题描述

有人可以告诉我如何根据文本值更改listview项目的文本颜色。我对此感到有点难过。



Can someone tell me how to change the text color of a listview item depending on the text value. I am a bit stumped on this.

ListViewItem lView = new ListViewItem();
lView.Text = "Main text";

if (productinfo.IndexOf("(SALE)", StringComparison.OrdinalIgnoreCase) > -1)
{
    lView.SubItems[1].ForeColor = Color.Red;
    lView.SubItems.Add(productprice);
}
lView.SubItems.Add(moreinfo);
lView.SubItems.Add(details);
lView.SubItems.Add(ability);
lView.SubItems.Add(links);
listView.Items.Add(lView);





谢谢



Thanks

推荐答案

你可以实现这个要求使用DrawItem事件,例如,如果这是Winform ListView Control,请查看下面的文档;

ListView.DrawItem事件 [ ^ ]
you can implement this requirement with DrawItem event, for example if this is Winform ListView Control check the documentation below;
ListView.DrawItem Event[^]


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

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