Dynamically resize a DropDownList in a grid when dropped down

Discussion in 'ASP .Net Web Controls' started by Keith-Earl, Apr 8, 2005.

  1. Keith-Earl

    Keith-Earl Guest

    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
    Keith-Earl, Apr 8, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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
    >
    Ken Cox [Microsoft MVP], Apr 13, 2005
    #2
    1. Advertising

  3. Keith-Earl

    Keith-Earl Guest

    Thanks. Will try very soon.

    Keith


    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:%...
    >> 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
    >>

    >
    Keith-Earl, Apr 13, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James J. Foster
    Replies:
    0
    Views:
    520
    James J. Foster
    Aug 7, 2003
  2. D A H
    Replies:
    1
    Views:
    1,574
    LenM22
    Jan 28, 2005
  3. Steffen Loringer

    Event if object is dropped out of the cache

    Steffen Loringer, Sep 28, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    355
    Kevin Spencer
    Sep 28, 2004
  4. msimmons
    Replies:
    0
    Views:
    460
    msimmons
    Jul 16, 2009
  5. Replies:
    2
    Views:
    1,251
    Adrienne
    Feb 13, 2005
Loading...

Share This Page