We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Drop Down List Item Width

JeepGeekin asked
Medium Priority
Last Modified: 2008-02-01
Hey. I need to create a drop down box with a specific width, but the text of the list items expand past this width. Is there a way to set the list width & the List object width seperately? Also, I have some tough requirements, so I need to keep the width = 150 and I have to use a DDL. I just need to find a  way to expand the viewable text area of the drop down items. Thanks!

<asp:DropDownList ID="ddlQuestion" runat="server" Width="150px">
<asp:ListItem Text="" />
<asp:ListItem Text="What is your all-time favorite sports team?" />
<asp:ListItem Text="What is your father's middle name?" />
<asp:ListItem Text="What was your high school mascot?" />
<asp:ListItem Text="What is your spouse's middle name?" />
<asp:ListItem Text="What is your best friend's last name?" />
<asp:ListItem Text="What is your pet's name?" />
<asp:ListItem Text="What is your mother's maiden name?" />
Watch Question

Elvio Lujan.Net Senior Developer

>>Is there a way to set the list width & the List object width seperately?

and if the width asignes to the ddl is minor that the length of the items it'll assume the item width


Thansk Lem, but I am going to leave this open for other ideas.
I am willing to consider javascript or other client side solution for this. Seems like there be a solution for this. Even if it is a creative one. I'll bump up the points.
Top Expert 2006
Hi JeepGeekin,

I'm having a hard time finding an example of what I'm about to reference, but basically when this issue comes up, what you must do is create a TextBox, an Image (or <img), a Panel (or <div>), and a ListBox.  Like so:

This is generally used for a ComboBox look and feel, like here:  http://www.codeproject.com/aspnet/combobox.asp

Your implementation would change it so the TextBox is ReadOnly.

<asp:TextBox runat="server" id="TextBox1" Width="150px" /><img src="downarrow.gif" onclick="showPanel()" />
<div style="display:none;border:solid 1px #000">
    <asp:ListBox runat="server" id="ListBox1" Rows="5" Width="200px" />

Basically you're recreating the functionality of a DropDownList.  Hopefully that ComboBox article will be of some help.  Just trying to give you an idea of one way to solve this...
-- Jason

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Here is a link with some info on your issue: http://icant.co.uk/forreview/tamingselect/

>> Is there a way to set the list width & the List object width seperately?
No, unless u create a custom control which beahaves like a dropdownlist .. its not going to be easy .. is it really worth the effort .. u culd always show tooltip of the selected item .. remember dropdownlist's tooltip does not work .. so wu ill have to write javascript function to show the selecteditem as a "div" tag .. just like a tooltip ..



Thanks guys for all the posts. Jason's tip is what I was looking for.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.