Posted 18 November 2019, 8:54 pm EST
Hi C1,
is seems a performance regression was introduced in recent builds: if a form contains several “C1.Win.Calendar.C1DateEdit” controls, creation of the form takes significantly longer in version .382.
See samples in attached zip file (click the first button in the form, the second button shows the workaround described below): with version .296. it takes 0,5 seconds to create the form on my machine. With version .382 (.Net 4.5.2), it takes 2 seconds for the same form. Most of the time seems to be lost in “C1DropDownControl.ApplyThemeToDropDownForm”.
C1DateEditPerformance.zip
Now for the interesting part (that’s the reason why I post this here instead of the support tracker, as others might find this workaround helpful): I subclassed “C1DateEdit” and override “DropDownFormCreationTime”:
protected override CreationTime DropDownFormCreationTime
{
get
{
return CreationTime.OnFirstCall;
}
}
This will delay creation of the dropdown.
Now performance is great: on first creation it takes 200 milliseconds, later calls will be at 10 milliseconds.
But this introduces another problem - this seems to be a bug in the control: if I set a value to C1DateEdit programatically, this value is not reflected in the dropdown when it is first shown.
My workaround in the subclass of C1DateEdit:
protected override void OnCreateDropDownFrom(DropDownForm dropDownForm)
{
base.OnCreateDropDownFrom(dropDownForm);
C1.Win.Calendar.DropDownCalendar ddc = (C1.Win.Calendar.DropDownCalendar)dropDownForm;
if (!(this.Value is System.DBNull))
{
PropertyInfo propInfo = ddc.GetType().GetProperty("SelectedDate", BindingFlags.Instance | BindingFlags.NonPublic);
propInfo.SetValue(ddc, this.Value);
}
}
Unfortunately, the property “SelectedDate” of “C1.Win.Calendar.DropDownCalendar” is not public, so I have to use reflection here.
Do you think more issues might arise because of the delayed creation of the dropdown?
Best regards
Wolfgang