473,408 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Change forecolor for individual listitems in CheckBoxList

I'm adding items to a CheckBoxList Control, and need the text in each
checkbox list item to be a specific color. Here's what I'm trying:

ListItem li = new ListItem(GroupName, GroupID);
li.Attributes.Add("ForeColor", GroupColor);
GroupList.Items.Add (li);

When viewing the produced HTML... there is no ForeColor attribute
being added. My guess is because each list item is really comprised
of two items: 1) CheckBox and 2) A label associated with it, and the
Attributes.Add is trying to add the forecolor atribute to the
CheckBox... not the label.

How can I get the text itself to a specified color?

I'd really like to use the CheckBoxList Control, if possible.

Do you think I need to derive a control from it, and override one of
the render methods?

Eric
Nov 18 '05 #1
1 2389
Hi Eric,

You've hit a well known bug[1]

[1]
http://groups.google.com/groups?q=bu...ftngp05&rnum=1

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
"Eric Robishaw" <er*******@getintheword.com> wrote in message
news:90*************************@posting.google.co m...
I'm adding items to a CheckBoxList Control, and need the text in each
checkbox list item to be a specific color. Here's what I'm trying:

ListItem li = new ListItem(GroupName, GroupID);
li.Attributes.Add("ForeColor", GroupColor);
GroupList.Items.Add (li);

When viewing the produced HTML... there is no ForeColor attribute
being added. My guess is because each list item is really comprised
of two items: 1) CheckBox and 2) A label associated with it, and the
Attributes.Add is trying to add the forecolor atribute to the
CheckBox... not the label.

How can I get the text itself to a specified color?

I'd really like to use the CheckBoxList Control, if possible.

Do you think I need to derive a control from it, and override one of
the render methods?

Eric

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TF | last post by:
Hi, Is there any way to change the text color of SOME of the ListBox(Windows Forms Control) items in VB.NET? TF
1
by: Ryan Scully | last post by:
Hello I have problem with determining exactly what CheckBoxList element is selected using JavaScript code. When I databind to the checkboxlist it renders it on the page and instead of giving each...
1
by: TJS | last post by:
can someone tell me why the selected item won't reflect user change in this little droplist example <%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object,...
0
by: Boris | last post by:
When I dynamically create CheckButtonList, I add ListItem(s) to my CheckButtonList object chkList chkList.Items.Add(new ListItem("My Text", "My Value")); The resulting HTML doesn't contain...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
9
by: matt | last post by:
is it possible to change a setting, such as Forecolor for all text in a form, or do you have to change it for each text block?
4
by: murthyspd | last post by:
Hi I have placed a listview on my Access form. There are certain reminders that I am sending through this listview. If the task is 2 days old and not yet completed, it should appear in red....
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
7
by: moondaddy | last post by:
in asp.net 2.0, i have a link buttonand want to change the forecolor in a mouse over event. how can I do this? -- moondaddy@noemail.noemail
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.