Customizing Close Button and Footer Panel in DateTimePicker for UI for WinForms
| Product Version | Product | Author |
|---|---|---|
| 2025.3.812 | RadGridView for WinForms | Dinko Krastev |
Description
In this tutorial, we will demonstrate how to customize the Close Button and Footer Panel in the UI for WinForms DateTimePicker.
Solution
Customizing the Close Button and Footer Panel
To customize the Close Button and Footer Panel:
- Subscribe to the
PopupControl.Openedevent to ensure the control is fully loaded. This ensures that the Footer Panel and Close Button are accessible for customization. - Apply custom colors to the Footer Panel and Close Button within the
PopupControl.Openedevent.
private void InitializeDateTimePicker()
{
this.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = true;
RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
calendarBehavior.PopupControl.Opened += PopupControl_PopupOpened;
}
private void PopupControl_PopupOpened(object sender, EventArgs e)
{
RadDateTimePickerDropDown dd = sender as RadDateTimePickerDropDown;
TimePickerDoneButtonContent buttonContent = ((RadPanel)dd.HostedControl).Controls[2] as TimePickerDoneButtonContent;
var buttonWrapElement = ((Telerik.WinControls.UI.TimePickerDoneButtonElement)(buttonContent.RootElement.Children[0]));
buttonWrapElement.BackColor = Color.Green;
var closeButton = buttonWrapElement.Children[0] as RadButtonElement;
closeButton.ForeColor = Color.White;
closeButton.ButtonFillElement.BackColor = Color.Blue;
closeButton.ButtonFillElement.NumberOfColors = 1;
}
Hiding the Resize Bar
To hide the Resize Bar:
- Access the
SizingGripelement of thePopupControl. - Set its
Visibilityproperty toElementVisibility.Collapsed.
Example code:
RadDateTimePickerCalendar calendarBehavior = this.dateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
calendarBehavior.PopupControl.SizingGrip.Visibility = ElementVisibility.Collapsed;
Ensure that you apply this property during initialization or within relevant events to avoid the Resize Bar reappearing.
Resolving Footer Panel Color Issue on First Open
To resolve the issue where the Footer Panel color does not apply on the first open, ensure you override the colors in the PopupControl.Opened event. This guarantees the correct behavior even when the control is opened for the first time.