Change Disabled BackColor of DateTimePicker & TimePicker

4 posts, 0 answers
  1. Mark
    Mark avatar
    32 posts
    Member since:
    Jan 2012

    Posted 20 Apr Link to this post

    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.

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 21 Apr Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mark
    Mark avatar
    32 posts
    Member since:
    Jan 2012

    Posted 21 Apr Link to this post

    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

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 25 Apr Link to this post

    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.
Back to Top