473,473 Members | 3,363 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Change color of an item in a listbox

Does anyone know how to show a listbox with different colors on its
itens?

Here goes what I've been trying to do:

On Page_OnLoad event I fill the dropdownlist and then I perform a FOR
to read this dropdownlist to change the color of some items in it but
this doesn't seem to work.
The line below is what I tried to use to perform this action but it
didn't work out

cbxCountry.Items(intPos).Attributes.CssStyle.Add(" color", "red")

Thanks in advance for any help about this.

Renato.
Nov 18 '05 #1
3 3116
Thanks a million Antony! It worked.

Cheers,

Renato
..NET Developer
http://www.infosolutions.com.br

"Marshal Antony" <do***********@hotmail.com> wrote in message news:<Ox*************@TK2MSFTNGP11.phx.gbl>...
Hi Renato,
This is a known bug with dropdownlist server control.I guess this is a
bug with Listbox server control as well.
In that case you need to use html control and make it runat="server".
So use,
<SELECT id="listBox1" size="20" runat="server"></SELECT>and add color
attribute for each item..
Hope this helps.
Regards,
Marshal Antony
.NET Developer
http://www.dotnetmarshal.com

0-ok0iojkopjp[l';?]tytyiRenato" <rc******@hotmail.com> wrote in message
news:16*************************@posting.google.co m...
Does anyone know how to show a listbox with different colors on its
itens?

Here goes what I've been trying to do:

On Page_OnLoad event I fill the dropdownlist and then I perform a FOR
to read this dropdownlist to change the color of some items in it but
this doesn't seem to work.
The line below is what I tried to use to perform this action but it
didn't work out

cbxCountry.Items(intPos).Attributes.CssStyle.Add(" color", "red")

Thanks in advance for any help about this.

Renato.

Nov 18 '05 #2
Hi Renato,
This is a known bug with dropdownlist server control.I guess this is a
bug with Listbox server control as well.
In that case you need to use html control and make it runat="server".
So use,
<SELECT id="listBox1" size="20" runat="server"></SELECT>and add color
attribute for each item..
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com

0-ok0iojkopjp[l';?]tytyiRenato" <rc******@hotmail.com> wrote in message
news:16*************************@posting.google.co m...
Does anyone know how to show a listbox with different colors on its
itens?

Here goes what I've been trying to do:

On Page_OnLoad event I fill the dropdownlist and then I perform a FOR
to read this dropdownlist to change the color of some items in it but
this doesn't seem to work.
The line below is what I tried to use to perform this action but it
didn't work out

cbxCountry.Items(intPos).Attributes.CssStyle.Add(" color", "red")

Thanks in advance for any help about this.

Renato.

Nov 18 '05 #3
Thanks a million Antony! It worked.

Cheers,

Renato
..NET Developer
http://www.infosolutions.com.br

"Marshal Antony" <do***********@hotmail.com> wrote in message news:<Ox*************@TK2MSFTNGP11.phx.gbl>...
Hi Renato,
This is a known bug with dropdownlist server control.I guess this is a
bug with Listbox server control as well.
In that case you need to use html control and make it runat="server".
So use,
<SELECT id="listBox1" size="20" runat="server"></SELECT>and add color
attribute for each item..
Hope this helps.
Regards,
Marshal Antony
.NET Developer
http://www.dotnetmarshal.com

0-ok0iojkopjp[l';?]tytyiRenato" <rc******@hotmail.com> wrote in message
news:16*************************@posting.google.co m...
Does anyone know how to show a listbox with different colors on its
itens?

Here goes what I've been trying to do:

On Page_OnLoad event I fill the dropdownlist and then I perform a FOR
to read this dropdownlist to change the color of some items in it but
this doesn't seem to work.
The line below is what I tried to use to perform this action but it
didn't work out

cbxCountry.Items(intPos).Attributes.CssStyle.Add(" color", "red")

Thanks in advance for any help about this.

Renato.

Nov 18 '05 #4

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

Similar topics

8
by: pothik05 | last post by:
Hello I am trying to change the color of individual entry in the listbox control based on some custom event. Can anyone please give any idea how to do it? Thanks
2
by: Danny | last post by:
Hello I am trying to create a separate listbox and fill it with items based on what is in another field in a database. This field is bound to a field in the underlying database. But the data...
3
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
2
by: Alpha | last post by:
How do I change the selected item in a listbox according to a Combox's selected item on the same form? The Combox is from a different table in the same dataset as the Listbox uses. Combox's...
2
by: simon | last post by:
I have list box populated with the dataReader. Then I add one item and I want that this item would be the first one in the listBox. Now, It's the last. Can I change the position of the item in the...
2
by: Renato | last post by:
Does anyone know how to show a listbox with different colors on its itens? Here goes what I've been trying to do: On Page_OnLoad event I fill the dropdownlist and then I perform a FOR to read...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
3
by: CSharper | last post by:
Is it possible to selectivly change the color of an item in text. I saw ForeColor option, but it changes the color of all the items. If it is not possible, is there any other control list listbox...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.