Changing the colour of certain ListView columns

孤者浪人 提交于 2019-12-10 09:55:03

问题


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;

回答1:


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.



来源:https://stackoverflow.com/questions/10234910/changing-the-colour-of-certain-listview-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!