DropDownList popup location after resizing items width

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    1 posts
    Member since:
    Feb 2014

    Posted 19 Jul 2015 Link to this post



    I used this solution to increase my DropDownList popup when item text is longer than ​DropDownList size. But when I open the DropDownList for the first time, it goes off the screen (my DropDownList is at the right edge of the form and popup isn't positioned correctly and goes right off the screen).

    ​Then when I ​close and ​open DropDownList, the popup position will be correct and after that everything is OK.


    Should I add something at the end of "PopupOpened" event after resizing items?


  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 21 Jul 2015 Link to this post

    Hello Kevin,

    Thank you for writing.

    I was not able to reproduce the observed behavior. This is why I wanted to ask you wich is the exact version  that you are using?

    Additionally, I want to suggest you a slightly different solution. You can use the PopupOpening event and set the width directly like this:
    public RadForm1()
        for (int i = 0; i < 5; i++)
            radDropDownList1.Items.Add("item " + i);
        radDropDownList1.Items.Add("Item with very long text, Item with very long text");
        radDropDownList1.PopupOpening += PopupOpening;
    void PopupOpening(object sender, CancelEventArgs e)
        int width = -1;
        foreach (var item in radDropDownList1.Items)
            int itemWidth = TextRenderer.MeasureText(item.Text, radDropDownList1.Font).Width;
            if (width < itemWidth)
                width = itemWidth;
        radDropDownList1.DropDownListElement.Popup.Width = width + 5;

    I hope this helps. I am looking forward to your reply.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top