Unplanned
Last Updated: 27 Feb 2024 13:02 by ADMIN
Chris
Created on: 27 Feb 2024 13:01
Category: DateTimePicker
Type: Bug Report
0
RadDateTimePicker: In VSTO project, the DropDown is not resized according to the DPI settings

Here is how it looks at 200 % DPI:

1 comment
ADMIN
Dinko | Tech Support Engineer
Posted on: 27 Feb 2024 13:02

Hello Chris,

Thank you for reporting this. A possible solution here is to manually scale the dropdown when it is open.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.radDateTimePicker1.DateTimePickerElement.PropertyChanged += DateTimePickerElement_PropertyChanged;
    }
    Size initialPopupSize;
    private void DateTimePickerElement_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName == "IsDropDownShown")
        {
            RadDateTimePickerCalendar calendar = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
            if (calendar.PopupControl.MinimumSize != initialPopupSize && initialPopupSize != Size.Empty)
            {
                return;
            }

            float scale = 0;
            float dpi = this.CreateGraphics().DpiX;

            if (dpi == 96)
            {
                scale = 1f;
            }
            else if (dpi == 120)
            {
                scale = 1.25f;
            }
            else if (dpi == 144)
            {
                scale = 1.5f;
            }
            else if (dpi == 192)
            {
                scale = 2f;
            }

            Size popupSize = calendar.PopupControl.Size;
            Size newSize = new Size((int)(popupSize.Width * scale), (int)(popupSize.Height * scale));
            calendar.PopupControl.MinimumSize = newSize;
            initialPopupSize = popupSize;
        }
    }
}

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.