Hello,
You can get to the ViewChanged event in much the same way as you have reached the calendar, via the CurrentBehavior. Please can you try the sample below which seems to work for me in some simple tests.
Imports
Telerik.WinControls.UI
Public
Class
Form1
Private
m_DateTimePickerEndDateMin
As
DateTime =
New
Date
(2010, 12, 28)
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
AddHandler
CType
(RadDateTimePickerEndDate.DateTimePickerElement.GetCurrentBehavior(), RadDateTimePickerCalendar).Calendar.ViewChanged,
AddressOf
RadDateTimePickerEndDate_ValueChanged
End
Sub
Private
Sub
RadDateTimePickerEndDate_ValueChanged(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
ChangeCalendarColours()
End
Sub
Private
Sub
RadDateTimePickerEndDate_Opened(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadDateTimePickerEndDate.Opened
ChangeCalendarColours()
End
Sub
Private
Sub
ChangeCalendarColours()
Dim
table
As
CalendarTableElement = TryCast(TryCast(
Me
.RadDateTimePickerEndDate.DateTimePickerElement.GetCurrentBehavior(), RadDateTimePickerCalendar).Calendar.CalendarElement.CalendarVisualElement.Children(0).Children(1), CalendarTableElement)
For
Each
cell
As
CalendarCellElement
In
table.Children
' check we are colouring date values and not M,T,W etc..
Dim
result
As
Integer
If
Integer
.TryParse(
CStr
(cell.Text), result)
Then
If
Date
.Compare(cell.
Date
, m_DateTimePickerEndDateMin) < 0
Then
cell.BackColor = Color.Red
Else
cell.BackColor = Color.Green
End
If
End
If
If
cell.[
Date
].DayOfWeek = DayOfWeek.Saturday
Or
cell.[
Date
].DayOfWeek = DayOfWeek.Sunday
Then
cell.BackColor = Color.Transparent
End
If
Next
End
Sub
End
Class
Hope that helps
Richard