Dynamically resize a DropDownList in a grid when dropped down

K

Keith-Earl

Not sure if you can do this, but we would like to dynamically resize the
width of a DDL in a grid when the DDL is dropped down. For example, please
consider this data:

AL - Alabama
AR - Arkansas
FL - Florida
etc.

We want to make our DDL pretty narrow so that it only shows the first two
characters of the string when the DDL is not dropped down. When the user
drops the list down we want to resize it wide enough to show the entire
string.

We essentially want to duplicate the behavior found in many rich client
environments such as MS Access. Access allows us to have multiple columns
in the dropped down portion of the control and only show the first column
when the DDL is not dropped down.

We could also assign a tool tip to the DDL if we could supply a unique tip
to each row in the DDL.

Any ideas?

Many thanks,

Keith
 
K

Ken Cox [Microsoft MVP]

Hi Keith,

It looks like you could make that work with some inline JavaScript and
Dynamic HTML. Here's a little demo code:

<asp:dropdownlist id="DropDownList1" runat="server" Width="40px"
OnFocus="this.style.width='120px'" OnBlur="this.style.width='40px'">
<asp:listitem Value="AL - Alabama">AL -
Alabama</asp:listitem>
<asp:listitem Value="AR - Arkansas">AR -
Arkansas</asp:listitem>
<asp:listitem Value="FL - Florida">FL -
Florida</asp:listitem>
</asp:dropdownlist>

You might want to look for an event that suits your needs better, other than
OnFocus. The available events are shown here:

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/select.asp

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
 
K

Keith-Earl

Thanks. Will try very soon.

Keith


Ken Cox said:
Hi Keith,

It looks like you could make that work with some inline JavaScript and
Dynamic HTML. Here's a little demo code:

<asp:dropdownlist id="DropDownList1" runat="server"
Width="40px" OnFocus="this.style.width='120px'"
OnBlur="this.style.width='40px'">
<asp:listitem Value="AL - Alabama">AL -
Alabama</asp:listitem>
<asp:listitem Value="AR - Arkansas">AR -
Arkansas</asp:listitem>
<asp:listitem Value="FL - Florida">FL -
Florida</asp:listitem>
</asp:dropdownlist>

You might want to look for an event that suits your needs better, other
than OnFocus. The available events are shown here:

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/select.asp

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

Keith-Earl said:
Not sure if you can do this, but we would like to dynamically resize the
width of a DDL in a grid when the DDL is dropped down. For example,
please consider this data:

AL - Alabama
AR - Arkansas
FL - Florida
etc.

We want to make our DDL pretty narrow so that it only shows the first two
characters of the string when the DDL is not dropped down. When the user
drops the list down we want to resize it wide enough to show the entire
string.

We essentially want to duplicate the behavior found in many rich client
environments such as MS Access. Access allows us to have multiple
columns in the dropped down portion of the control and only show the
first column when the DDL is not dropped down.

We could also assign a tool tip to the DDL if we could supply a unique
tip to each row in the DDL.

Any ideas?

Many thanks,

Keith
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top