style 'bold' doesn't work in code

  • Thread starter Thread starter Luc
  • Start date Start date
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)
 
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.
 
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.
 
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.
 
Back
Top