473,387 Members | 1,553 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,387 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 3114
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
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.