// Add a subitem called revenueItem
ListViewItem.ListViewSubItem revenueItem = entryListItem.SubItems.Add("Revenue");
// Change the revenueItem object's color and font.
revenueItem.ForeColor = System.Drawing.Color.Blue;
revenueItem.Font = new System.Drawing.Font("Times New Roman", 10, System.Drawing.FontStyle.Bold);
Alex S. Andr...
Member
9 Points
17 Posts
How do i color an item in a listview component?
Apr 09, 2012 01:07 PM|LINK
Hello!!
I needs to color an item in a listview at runtime.
Anyone have any suggestion?
Best regards
cool.asp
Member
544 Points
188 Posts
Re: How do i color an item in a listview component?
Apr 09, 2012 01:55 PM|LINK
// Add a subitem called revenueItem ListViewItem.ListViewSubItem revenueItem = entryListItem.SubItems.Add("Revenue"); // Change the revenueItem object's color and font. revenueItem.ForeColor = System.Drawing.Color.Blue; revenueItem.Font = new System.Drawing.Font("Times New Roman", 10, System.Drawing.FontStyle.Bold);That is from examples here at this page: http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.listviewsubitem.forecolor%28v=vs.100%29.aspx
Alex S. Andr...
Member
9 Points
17 Posts
Re: How do i color an item in a listview component?
Apr 09, 2012 02:30 PM|LINK
Hello cool.asp!
Thanks for reply but this example explain how to color a app windows.forms.
i tried to convert to a web app based it but don't exists the subitem property.
Best regards
cool.asp
Member
544 Points
188 Posts
Re: How do i color an item in a listview component?
Apr 09, 2012 02:33 PM|LINK
Try adding this to top of .aspx.cs
Alex S. Andr...
Member
9 Points
17 Posts
Re: How do i color an item in a listview component?
Apr 09, 2012 02:57 PM|LINK
don't works.
i'm developing a web application instead.
Johnson-zhu
Member
340 Points
45 Posts
Re: How do i color an item in a listview component?
Apr 11, 2012 09:01 AM|LINK
Hi Alex,
If you are developing a web application, please following this link:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemdatabound.aspx
Hope you will get some help from it.
ramiramilu
All-Star
95413 Points
14106 Posts
Re: How do i color an item in a listview component?
Apr 11, 2012 10:28 AM|LINK
Handle ListView ItemDatabound and in there you can change BgColor for a particular ITem - http://forums.asp.net/t/1548526.aspx/1
Thanks,
JumpStart
shivv
Participant
1566 Points
283 Posts
Re: How do i color an item in a listview component?
Apr 11, 2012 11:53 AM|LINK
You can do some thing like below:
ListItem item1 = new ListItem(); item1.Attributes.Add("style", "color: red;"); item1.Text = "item 1"; ListBox1.Items.Add(item1);