New to Telerik UI for WinForms? Download free 30-day trial

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

To customize the Close Button and Footer Panel:

  1. Subscribe to the PopupControl.Opened event to ensure the control is fully loaded. This ensures that the Footer Panel and Close Button are accessible for customization.
  2. Apply custom colors to the Footer Panel and Close Button within the PopupControl.Opened event.

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:

  1. Access the SizingGrip element of the PopupControl.
  2. Set its Visibility property to ElementVisibility.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.

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.

See Also

In this article