Unplanned
Last Updated: 09 May 2023 10:32 by ADMIN
Jakub
Created on: 09 May 2023 09:55
Category: DropDownList
Type: Bug Report
0
RadDropDownList: The Height/Width of the control is not changed to fit the selected item with an image in the DropDownStyle=DropDownList scenario
The control does not expand to fit the selected item when it has an image and the DropDownStyle is set to DropDownList.
1 comment
ADMIN
Dinko | Tech Support Engineer
Posted on: 09 May 2023 10:32

Hi Jakub,

Thank you for reporting this.

To make this work, you need to create a custom RadDropDownListElement and return a custom RadDropDownListEditableAreaElement. Inside the second custom class, you need to override the MeasureOverride method to correctly measure the elements.

public class CustomRadDropDownListElement : RadDropDownListElement
{
    protected override RadDropDownListEditableAreaElement CreateTextEditorElement()
    {
        return new CustomListEditableAreaElement(this);
    }
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadDropDownListElement);
        }
    }

}
public class CustomListEditableAreaElement : RadDropDownListEditableAreaElement
{
    public CustomListEditableAreaElement(RadDropDownListElement owner) : base(owner)
    {

    }
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadDropDownListEditableAreaElement);
        }
    }
    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        var elementsDesiredSize = base.MeasureOverride(availableSize);
        SizeF clientSize = this.GetClientRectangle(availableSize).Size;


        SizeF desiredSize = this.Layout.Measure(clientSize);
        // This measures the size of the underlying text box:

        return this.CalculateDesiredSize(availableSize, desiredSize, elementsDesiredSize);
    }
}

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.