style 'bold' doesn't work in code

L

Luc

Hi,

i want the first item in the dropdownlist to be red and bold (VB.net).
Red works, but not bold. An suggestion is welcome.
Thanks
Luc

z1 = New ListItem("choose an item", 0)
z1.Attributes.Add("style", "font-bold:true;background-color:red")
DropDownList1.Items.Add(z1)
 
R

Registered User

thanks for answering, but i tried that too without succes ..
I believe that style is a collection of attributes rather than a
specific attribute. In any case this is works for me.

z1.Attributes.Add("font-weight", "bold");
z1.Attributes.Add("background-color", "red");

regards
A.G.
 
L

Luc

It still doesn't work to me.
I found this comment about this:

"Hi, you can not bold the list or combo box items invidually, even you can
not change the font styles of a single item except forecolors. "

Sure it works to you?

Registered User said:
thanks for answering, but i tried that too without succes ..
I believe that style is a collection of attributes rather than a
specific attribute. In any case this is works for me.

z1.Attributes.Add("font-weight", "bold");
z1.Attributes.Add("background-color", "red");

regards
A.G.
 
R

Registered User

It still doesn't work to me.
I found this comment about this:

"Hi, you can not bold the list or combo box items invidually, even you can
not change the font styles of a single item except forecolors. "

Sure it works to you?
I was unaware of the specific control and thinking general html
controls. If z1 is of type System.Web.UI.WebControls.DropDownList why
not simply use the object's properties to manipulate the list
properties.

z1.Font.Bold = true;
z1.ForeColor = Color.Red;

If you want to manipulate the individual elements of the list you
should investigate deriving a suitable control. Here is a good place
to start.

http://msdn.microsoft.com/en-us/library/aa479311.aspx

regards
A.G.
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top