473,805 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
+ 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.Item s(intPos).Attri butes.CssStyle. Add("color", "red")

Thanks in advance for any help about this.

Renato.
Nov 18 '05 #1
3 3160
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******* ******@TK2MSFTN GP11.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******@hotma il.com> wrote in message
news:16******** *************** **@posting.goog le.com...
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.Item s(intPos).Attri butes.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******@hotma il.com> wrote in message
news:16******** *************** **@posting.goog le.com...
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.Item s(intPos).Attri butes.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******* ******@TK2MSFTN GP11.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******@hotma il.com> wrote in message
news:16******** *************** **@posting.goog le.com...
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.Item s(intPos).Attri butes.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
15169
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
3045
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 is changed from another list box that is a pulldown of the 3 items. This way they are forced to select one of the 3 items. So when the field updates based on the item chosen, why doesnt it cause the "on change event" to happen? The field has...
3
3545
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 selects one item out of the 'all selected' listing then there is now only one item selected. How and where can I put in some code to change the selected radio button to the 'include' since it is no longer in select all mode. Thanks, Alpha
2
3332
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 ValueMember is a ID that is a column in the table that the listbox uses. Is there a way to link these 2's relation so that when the user changes the selection in the Combox the list box would automacticall changes to reflect the items that's linked to...
2
2801
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 listBox from the last to the first? lstMedia.DataSource() = funkcije.createDataReader(sql, True) lstMedia.DataValueField = "med_id" lstMedia.DataTextField = "med_name" lstMedia.DataBind()
2
270
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 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
1
4955
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 and a forest green border. However, when you move the cursor from one item to the next within the listbox or you click on an item in the listbox to select it, the background turns to the standard windows dark blue with white letters. Well, that...
4
6144
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 extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub Page_Load(..........) Dim dSet As DataSet Dim sqlConn As SqlConnection
3
29320
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 where we can see more than one item and change the color during run time. Thanks.
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10607
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6875
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
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 we have to send another system
3
3007
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.