
Cory Hudson
Top achievements
Rank 2
Cory Hudson
asked on 31 Aug 2009, 07:58 PM
Hello,
I am trying to change the color of a single data bound item within a RadListBox control, but I am not exactly sure when/where I should do this.
I tried something along these lines, but I am not getting the text Color to change.
Does anyone know what I should do differently? (pre-render, different item attribute etc?)
I am trying to change the color of a single data bound item within a RadListBox control, but I am not exactly sure when/where I should do this.
I tried something along these lines, but I am not getting the text Color to change.
protected void listBoxLocations_ItemDataBound(object sender, RadListBoxItemEventArgs e) |
{ |
if (attribute) |
e.Item.ForeColor = System.Drawing.Color.Gray; |
} |
Does anyone know what I should do differently? (pre-render, different item attribute etc?)
4 Answers, 1 is accepted
0

Cory Hudson
Top achievements
Rank 2
answered on 31 Aug 2009, 08:55 PM
So, I have played with this a bit more and I can get some things to work in ItemDataBound or Pre-Render. I also added a css class to the item
Now, I get the all the elements of the css class, except I do not get the red text color. Given that I know next to nothing about css, is my issue a css thing? Any other thoughts?
Thanks,
Cory
protected void listBoxLocations_ItemDataBound(object sender, RadListBoxItemEventArgs e) |
{ |
if (attribute) |
e.Item.CssClass = "css1"; |
} |
.css1 |
{ |
background-color: #E5E5E5; |
text-align:right; |
color:Red; |
} |
Now, I get the all the elements of the css class, except I do not get the red text color. Given that I know next to nothing about css, is my issue a css thing? Any other thoughts?
Thanks,
Cory
0
Hi Cory Hudson,
Actually the red color is applied when I tested it.
Here is my simple test:
Best wishes,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Actually the red color is applied when I tested it.
Here is my simple test:
<telerik:RadComboBox ID="RadComboBox1" runat="server"> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" |
Value="RadComboBoxItem1" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" CssClass="css1" |
Value="RadComboBoxItem2" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" |
Value="RadComboBoxItem3" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4" |
Value="RadComboBoxItem4" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem5" |
Value="RadComboBoxItem5" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem6" |
Value="RadComboBoxItem6" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem7" |
Value="RadComboBoxItem7" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem8" |
Value="RadComboBoxItem8" /> |
</Items> |
</telerik:RadComboBox> |
<style type="text/css"> |
.css1 |
{ |
background-color: Aqua; |
text-align:rightright; |
color:Red; |
} |
</style> |
Best wishes,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Cory Hudson
Top achievements
Rank 2
answered on 01 Sep 2009, 05:35 PM
Thanks for the reply Veselin, but there are 2 things different here.
1. I am using a data bound RadListBoxControl.
2. Programmatic (conditional) assignment of the css class to a single item within the List Box.
When I do this to the list box, I can get a variety of css styles to apply, but never the text color...
Any thoughts?
1. I am using a data bound RadListBoxControl.
2. Programmatic (conditional) assignment of the css class to a single item within the List Box.
When I do this to the list box, I can get a variety of css styles to apply, but never the text color...
Any thoughts?
0

Cory Hudson
Top achievements
Rank 2
answered on 02 Sep 2009, 09:29 PM
I found a solution to this by creating a custom skin and removing the default reference to color: #000;
Now I can set the forecolor of ListBox items to whatever i want via code.
Now I can set the forecolor of ListBox items to whatever i want via code.