Approved
Last Updated: 04 Oct 2016 08:00 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 05 Sep 2016 06:50
Category: PropertyGrid
Type: Bug Report
1
FIX. RadPropertyGrid - DropDownMinSize is not respected when setting in the EditorInitialized event
To reproduce:

public Form1()
{
    InitializeComponent();

    this.radPropertyGrid1.SelectedObject = new Item(123,"Item123",DateTime.Now.AddDays(20));
    this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized;
}

private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
{
    PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor;
    if (propertyGridDateTimeEditor != null)
    {              
        BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement;
        if (dateTimeEditorElement != null)
        {
            dateTimeEditorElement.Format = DateTimePickerFormat.Long;
    
            dateTimeEditorElement.ShowTimePicker = true;
            var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar;
            if (radDateTimePickerCalendar != null)
            { 
                radDateTimePickerCalendar.DropDownMinSize = new System.Drawing.Size(600, 400);
            }
        }
    }
} 

public class Item
{
    public int Id { get; set; }

    public string Name { get; set; }

    public DateTime Date { get; set; }

    public Item(int id, string name, DateTime date)
    {
        this.Id = id;
        this.Name = name;
        this.Date = date;
    }
}

Workaround:

private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
{
    PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor;
    if (propertyGridDateTimeEditor != null)
    {              
        BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement;
        if (dateTimeEditorElement != null)
        {
            dateTimeEditorElement.Format = DateTimePickerFormat.Long;
    
            dateTimeEditorElement.ShowTimePicker = true;
            var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar;
            if (radDateTimePickerCalendar != null)
            {
                radDateTimePickerCalendar.PopupControl.PopupOpened-=PopupControl_PopupOpened;
                radDateTimePickerCalendar.PopupControl.PopupOpened+=PopupControl_PopupOpened;
            }
        }
    }
}

private void PopupControl_PopupOpened(object sender, EventArgs args)
{
    RadDateTimePickerDropDown dropdown = sender as RadDateTimePickerDropDown;
    dropdown.MinimumSize = new Size(600, 300);
}
0 comments