Home All Groups Group Topic Archive Search About

Dynamically resize a DropDownList in a grid when dropped down

Author
8 Apr 2005 1:12 PM
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

Author
13 Apr 2005 1:32 PM
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

Show quoteHide quote
"Keith-Earl" <keith_NO_SPAM_HERE_rowe79@hotmail.com> wrote in message
news:%23bFrayDPFHA.2520@tk2msftngp13.phx.gbl...
> 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
>
Author
13 Apr 2005 1:44 PM
Keith-Earl
Thanks.  Will try very soon.

Keith


Show quoteHide quote
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message
news:ezS9C1CQFHA.244@TK2MSFTNGP12.phx.gbl...
> 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" <keith_NO_SPAM_HERE_rowe79@hotmail.com> wrote in message
> news:%23bFrayDPFHA.2520@tk2msftngp13.phx.gbl...
>> 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
>>
>
Author
24 Mar 2006 4:10 PM
ht055
Hi,

The code work fine. The problem is first time click, it reset the width, then i have click again to select the item in the list.

Is the a way to make it more friendly clicking? I means one you click on the DDL  then you can select the item in the DDL.

Help help.

Thanks. -- ht055 ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------