I am using Version 2016.2.608.20 of WinControls.UI.
WHERE IS PERFORMCLICK EVENT?
My client is very particular that they do not want anyone hand-typing a date into a control, so I need the date part of the DateTimePicker to be read-only. Unfortunately, all attempts to do this do not work, and it appears that is not supported. My workaround is a standard LABEL control placed OVER the date area of the DateTimePicker, with a painted border. But the client wants to be able to CLICK on that now and have the calendar appear.
I considered using a standard RadButton and RadCalendar, but then I need to do a lot of extra work to make it extend beyond the modal dialog form bounds, etc. I am hoping there is an easier way to just do a built-in PERFORMCLICK, if only I can find where it's hidden.
DISABLE SUNDAYS ON THE CALENDAR
I found other answers to this question, and it certainly makes the Sunday dates APPEAR disabled, but they can still click on them, and the date changes. I am handling in the CLOSED event, adjusting the date accordingly to the next Monday... but it would be better if the Sundays actually stayed disabled / un-clickable.
HIDE THE CLEAR BUTTON
Minor issue, I can show the footer and disable the clear button... but is there any way to completely remove it? (They like having the [TODAY] button in the footer. This is minor... they can live with a disabled button... but if there's an easy way to hide it, how?
Thanks for your help!
Here is my code:
/// PART ONE - WHERE IS THE PERFORMCLICK EVENT?
private
void
MyLabel_MouseClick(
object
sender, MouseEventArgs e)
{
// Attempts to locate the PerformClick event...
MyRadDateTimePicker.DateTimePickerElement.PerformClick();
MyRadDateTimePicker.DateTimePickerElement.ArrowButton.PerformClick();
foreach
(Telerik.WinControls.RadElement _Element
in
MyRadDateTimePicker.DateTimePickerElement.ArrowButton.Children)
_Element.PerformClick();
foreach
(Telerik.WinControls.RadElement _Element
in
MyRadDateTimePicker.DateTimePickerElement.Calendar.CalendarElement.Children)
_Element.PerformClick();
}
// PART TWO - HOW TO DISABLE SUNDAYS IN CALENDAR
private
void
MyRadDateTimePicker_Opened(
object
sender, EventArgs e)
{
MyRadDateTimePicker.DateTimePickerElement.Value =
this
.SelectedDate;
RadCalendar _Calendar = MyRadDateTimePicker.DateTimePickerElement.Calendar;
CalendarTableElement _Table
= (CalendarTableElement)_Calendar.CalendarElement.CalendarVisualElement.Children[0].Children[1];
foreach
(CalendarCellElement _Cell
in
_Table.Children)
{
if
(_Cell.Date.DayOfWeek == DayOfWeek.Sunday)
{
_Cell.Enabled =
false
;
// Disables, but still leaves it clickable
}
}
_Calendar.ClearButton.Enabled =
false
;
// Would actually prefer to HIDE this!
_Calendar.ShowFooter =
true
;
}