列表视图控件和颜色 [英] listview control and colors

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

问题描述



我正在尝试根据列表文本的文本更改背景颜色.

问题是,每次 重新粉刷.我尝试了refresh()和update()函数来制作项目 保持它们的颜色,但是不起作用.

我没有看到任何其他函数或属性可以解决我遇到的这个问题.

因此,如果有人对如何做到这一点(最好是没有ownerdraw的情况),我将非常感谢您的帮助.

在此先感谢您!

Hi,

I am trying to change the background color of the listview items depending on their text.

The problem is, the items don't keep their background color after every repaint. I tried the refresh() and update() function to make the items keep their color, but that didn't work.

I don't see any other function or property which might fix this problem i'm having.

So if anyone has a suggestion on how to do this (preferable without  ownerdraw) i'd really appreciate the help.

Thanks in advance!

推荐答案

private void Form1_Load (对象发送方,EventArgs e)
{
listView1.Items.Add(红色"); 黄色");

listView1.Items [0] .BackColor = Color.Red;
listView1.Items [1] .BackColor = Color.Green;
listView1.Items [2] .BackColor = Color.Yellow; >}

这些项目似乎不会改变其背景颜色.
您怎么会遇到这种情况?

private void Form1_Load(object sender, EventArgs e)
        {
            listView1.Items.Add("red");
            listView1.Items.Add("greend");
            listView1.Items.Add("yellow");

            listView1.Items[0].BackColor = Color.Red;
            listView1.Items[1].BackColor = Color.Green;
            listView1.Items[2].BackColor = Color.Yellow;
        }

It seems that the items will not change their background color..
How can you get into this situation?


这篇关于列表视图控件和颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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