This is a migrated thread and some comments may be shown as answers.

Change Disabled BackColor of DateTimePicker & TimePicker

3 Answers 569 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 20 Apr 2016, 02:51 PM

Hi,

I am trying to set the backcolor of the DateTimePicker and TimePicker when disabled. I am already overriding the OnEnabledChanged event to replace the TextBoxElement with our custom text box so I can update the forecolor and this is all working OK and the backcolor of the textbox is correct, however the control border, dropdown arrow, etc. are still using the old color and I am unable to work out what properties I need to update to access these items.

How do i update the backcolor of all of the visible items for the entire DateTimePicker and for a TimePicker?

 

Thanks,

 

Mark.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 Apr 2016, 01:17 PM
Hello Mark,

Thank you for writing.

You can edit the predefined themes and set the color of the disabled state (see attached image). More information is available in the following articles:
Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Mark
Top achievements
Rank 1
answered on 21 Apr 2016, 01:30 PM

Hi,

Thanks for getting back to me. The theme mechanism looks great, but isn't something we are using in our current application so i am looking to update the controls disabled colour programatically.

Many thanks,

Mark

0
Dimitar
Telerik team
answered on 25 Apr 2016, 08:42 AM
Hello Mark,

Thank you for writing back.

You can use the SetThemeValueOverride method to change the styles set in the theme. For example:
radTimePicker1.TimePickerElement.SetThemeValueOverride(VisualElement.BackColorProperty, Color.Red, "Disabled" , "TimePickerFill");
radTimePicker1.TimePickerElement.SetThemeValueOverride(VisualElement.BackColorProperty, Color.Red, "Disabled", "TimePickerBorder");
radTimePicker1.TimePickerElement.MaskedEditBox.SetThemeValueOverride(RadItem.BackColorProperty, Color.Red, "Disabled");
 
radDateTimePicker1.DateTimePickerElement.TextBoxElement.SetThemeValueOverride(RadItem.BackColorProperty, Color.Red, "Disabled");
radDateTimePicker1.DateTimePickerElement.ArrowButton.SetThemeValueOverride(VisualElement.BackColorProperty, Color.Red, "Disabled","RadArrowButtonFill");
radDateTimePicker1.DateTimePickerElement.ArrowButton.SetThemeValueOverride(VisualElement.BackColorProperty, Color.Red, "Disabled", "RadArrowButtonBorder");

You can use Visual Style Builder to determine which elements have a disabled state and use the above method to override the theme settings.

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Mark
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Mark
Top achievements
Rank 1
Share this question
or