473,382 Members | 1,424 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,382 software developers and data experts.

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 3113
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.