RadDateTimePicker Problem with Click events

9 posts, 1 answers
  1. RAGHAVENDRA
    RAGHAVENDRA avatar
    17 posts
    Member since:
    Dec 2010

    Posted 29 Dec 2010 Link to this post

    Private Sub RadDateTimePickerEndDate_Opened(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadDateTimePickerEndDate.Opened
     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
                If cell.Date < Me.DateTimePickerEndDateMin Then
                    cell.BackColor = Color.Red
                Else
                    cell.BackColor = Color.Green
                End If
                If cell.[Date].DayOfWeek = DayOfWeek.Saturday Or cell.[Date].DayOfWeek = DayOfWeek.Sunday Then
                    cell.BackColor = Color.Transparent
                End If
            Next
        End Sub

    Hello All,
    This is the code I am using to set the back ground color of the cells in the calendar control based on the min date.
    1)I open the calendar  the back color for all the dates less than the min date is showing up as red. Let us assume the min date is 6/12/2000
    Now when I go to next month(i.e., 7/12/2000) the back color for all the cells in that month is supposed to be green. But this is not the case. Whats happening is that some of the Cells color is still Red and the others are green. But if i reopen the Calendar all the dates show up as Green. Now if I go back to 6/12/2000 all the dates including dates less than 12 th of June are showing up as Green too.
    Is there any other event in which this code needs to be executed when i change the month using the arrow on the top of raddatepicker. I am using raddatetimepicker for winforms. Q3 2010 version. I do not see a viewchanged event here. Any help would be appreciated.

    Thanks a lot.
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 29 Dec 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. RAGHAVENDRA
    RAGHAVENDRA avatar
    17 posts
    Member since:
    Dec 2010

    Posted 29 Dec 2010 Link to this post

    Hello Richard,
    Thanks a lot for your help. It solved my issue.

    Thanks Prata.
  5. RAGHAVENDRA
    RAGHAVENDRA avatar
    17 posts
    Member since:
    Dec 2010

    Posted 29 Dec 2010 Link to this post

    Richard,
    Also,  Where can I set the no of months to be passed through when I press the double arrow on the RadDateTimePicker.
    I think we need to drill down deep into the properties but could not find it. It would be great if you can help me with this too.
    Thanks
    Prata.
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 29 Dec 2010 Link to this post

    Hi,

    You can change the Fast Navigation Step on the calendar in this way.
    CType(RadDateTimePickerEndDate.DateTimePickerElement.GetCurrentBehavior(), RadDateTimePickerCalendar).Calendar.FastNavigationStep = 12

    Hope that helps, but let me know if you have any further questions
    Thanks
    Richard
  7. PROGRA
    PROGRA avatar
    7 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2013 Link to this post

    Disculpen Tengo Un PROBLEMA CON EL RADDATETIMEPICKER QUIERO CREAR UNA CLASE SOBRE EL COMPONENTE PARA TENER EL COMPONENTE CON MIS FORMATO Y FUNCIONALIDAD DEFINIDA PERO AL SOLO HEREDAR LA CLASE Telerik.WinControls.UI.RadDateTimePicker CUANDO SE PONE EL COMPONENETE ES HABILITADO
    LE APARECE UN
    Contorno MAS OSCURO COMO PUEDO QUITARLO????


  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Jun 2013 Link to this post

    Hi,

    I would kindly ask you to post your question in English in order to allow us to address your question for you. Please note that English is the official language for correspondence with the support teams in Telerik, hence we will ask you to post all future questions in English.

    Thank you for the understanding.
     

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. PROGRA
    PROGRA avatar
    7 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    Sorry I have A PROBLEM WITH RADDATETIMEPICKER WANT TO CREATE A CLASS ON THE COMPONENT COMPONENT TO BE WITH MY FORM AND FUNCTION DEFINED BUT ONLY TO INHERIT THE CLASS WHEN PUTTING Telerik.WinControls.UI.RadDateTimePicker Componenet IS Enabled
    COMES A
    DARKER Contour CAN I REMOVE????
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Jun 2013 Link to this post

    Hi,

    Although I am still not sure what you are trying to ask, I would guess that you are inheriting from RadDateTimePicker and the control does not look as expected. If this is the case, please take a look at the following article regarding this matter: http://www.telerik.com/support/kb/winforms/general/inherit-themes-from-radcontrols.aspx.

    If this is not the case, please try to rephrase your question so I can understand your requirement and help you achieve it.
     
    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready