Skip to content

Commit ee9ea8d

Browse files
authored
Merge pull request #814 from telerik/new-kb-datetimepicker-customizing-footer-panel-2a1548a4f6584c57a85c8c64818a9992
Added new kb article datetimepicker-customizing-footer-panel
2 parents 25db98d + 563224e commit ee9ea8d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Customizing Close Button and Footer Panel in DateTimePicker for UI for WinForms
3+
description: Learn how to customize the Close Button and Footer Panel in the DateTimePicker for UI for WinForms, including steps to hide the resize bar and set colors.
4+
type: how-to
5+
page_title: How to Customize Close Button and Footer Panel in DateTimePicker for UI for WinForms
6+
meta_title: How to Customize Close Button and Footer Panel in DateTimePicker for UI for WinForms
7+
slug: datetimepicker-customizing-footer-panel
8+
tags: editors, datetimepicker, ui-for-winforms, footerpanel, close-button, customization, popupcontrol, opened-event, sizinggrip
9+
res_type: kb
10+
ticketid: 1577254
11+
---
12+
13+
|Product Version|Product|Author|
14+
|----|----|----|
15+
|2025.3.812|RadGridView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)|
16+
17+
## Description
18+
In this tutorial, we will demonstrate how to customize the Close Button and Footer Panel in the [UI for WinForms DateTimePicker](https://docs.telerik.com/devtools/winforms/controls/editors/datetimepicker/overview).
19+
20+
## Solution
21+
22+
### Customizing the Close Button and Footer Panel
23+
24+
To customize the Close Button and Footer Panel:
25+
26+
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.
27+
2. Apply custom colors to the Footer Panel and Close Button within the `PopupControl.Opened` event.
28+
29+
````C#
30+
31+
private void InitializeDateTimePicker()
32+
{
33+
this.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = true;
34+
35+
RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
36+
calendarBehavior.PopupControl.Opened += PopupControl_PopupOpened;
37+
}
38+
39+
private void PopupControl_PopupOpened(object sender, EventArgs e)
40+
{
41+
RadDateTimePickerDropDown dd = sender as RadDateTimePickerDropDown;
42+
TimePickerDoneButtonContent buttonContent = ((RadPanel)dd.HostedControl).Controls[2] as TimePickerDoneButtonContent;
43+
44+
var buttonWrapElement = ((Telerik.WinControls.UI.TimePickerDoneButtonElement)(buttonContent.RootElement.Children[0]));
45+
buttonWrapElement.BackColor = Color.Green;
46+
var closeButton = buttonWrapElement.Children[0] as RadButtonElement;
47+
closeButton.ForeColor = Color.White;
48+
closeButton.ButtonFillElement.BackColor = Color.Blue;
49+
closeButton.ButtonFillElement.NumberOfColors = 1;
50+
}
51+
52+
````
53+
54+
### Hiding the Resize Bar
55+
56+
To hide the Resize Bar:
57+
58+
1. Access the `SizingGrip` element of the `PopupControl`.
59+
2. Set its `Visibility` property to `ElementVisibility.Collapsed`.
60+
61+
Example code:
62+
63+
````C#
64+
65+
RadDateTimePickerCalendar calendarBehavior = this.dateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
66+
calendarBehavior.PopupControl.SizingGrip.Visibility = ElementVisibility.Collapsed;
67+
68+
````
69+
70+
Ensure that you apply this property during initialization or within relevant events to avoid the Resize Bar reappearing.
71+
72+
### Resolving Footer Panel Color Issue on First Open
73+
74+
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.
75+
76+
## See Also
77+
78+
- [UI for WinForms DateTimePicker Documentation](https://docs.telerik.com/devtools/winforms/controls/editors/datetimepicker/overview)
79+
- [Event Handling in UI for WinForms](https://docs.telerik.com/devtools/winforms/getting-started/events-overview)
80+
- [Customizing UI Elements in UI for WinForms](https://docs.telerik.com/devtools/winforms/customizing-ui-elements)

0 commit comments

Comments
 (0)