Change color of an item in a listbox

R

Renato

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.
 
M

Marshal Antony

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
 
R

Renato

Thanks a million Antony! It worked.

Cheers,

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

Marshal Antony said:
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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top