更改某些ListView控件列的颜色 [英] Changing the colour of certain ListView columns

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

问题描述

我怎样才能改变一个特定列的颜色在ListView?

 字符串[]行= {APPID [I],启动游戏}; //更多的数据添加listView1.Items.Add(nameArray [I],i)的.SubItems.AddRange(行);listView1.ForeColor = System.Drawing.Color.Blue;


解决方案

尝试是这样的:

  ListViewItem的ITEM1 =新的ListViewItem(项目1);
item1.SubItems.Add(颜色);
item1.SubItems [1] .ForeColor = System.Drawing.Color.Blue;
item1.UseItemStyleForSubItems = FALSE;
listView1.Items.Add(ITEM1);

如果您正在使用的数据库绑定它,你可能对项目数据绑定过程中做到这一点。让我知道如果是这样的话。

How can I change the colour of a specific column in a listview?

string[] row = { appID[i], "Launch Game"}; // more data to add

listView1.Items.Add(nameArray[i], i).SubItems.AddRange(row);

listView1.ForeColor = System.Drawing.Color.Blue;

解决方案

Try something like this:

ListViewItem item1 = new ListViewItem( "Item 1"); 
item1.SubItems.Add( "Color" ); 
item1.SubItems[1].ForeColor = System.Drawing.Color.Blue;
item1.UseItemStyleForSubItems = false; 
listView1.Items.Add( item1 ); 

If you are using database to bind it you may have to do this during on item databind process. Let me know if that's the case.

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

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