RadGridView - Custom Calendar Editor Control

4 posts, 0 answers
  1. Theo
    Theo avatar
    19 posts
    Member since:
    Sep 2011

    Posted 07 Jan 2013 Link to this post

    Requirements

    RadControls version 2012.3.1017.40
    .NET version 4.0+
    Visual Studio version 2012/2010
    programming language VB.NET / C#

    PROJECT DESCRIPTION
    I was recently tasked with creating our own implementation of the Calendar editor control for the WinForms RadGridView. The requirement was that it should behave like the windows calendar control accessed from your system date on the desktop. The key behavior that was required was the navigation between months and years


    Attached is a full solution with a VB.NET and C# project as well as a Word Document with screen shots and descriptions.
    Thank you
    Theo Jacobs


  2. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 10 Jan 2013 Link to this post

    Hello Theo,

    Thank you for sharing your solution with the community. I am sure that it will benefit from it.

    I have added 3000 Telerik Points to your account for your time and efforts.

    Kind regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. Theo
    Theo avatar
    19 posts
    Member since:
    Sep 2011

    Posted 22 Jan 2013 Link to this post

    Just a quick note. I picked up an undocumented feature in the code.
    If you look at MyDateTimeEditorElement line 97. There is a problem in that if your current date for instance is 31 January and you select February from the Month Grid, the date is not properly updated as 31 Jan is after the last day that is available in Feb.

    Correction
    'Check if the current date has a value, if so, use the selected date, else use the current system day
    Dim lastDayOfMonth As Integer = New DateTime(CInt(DropDownMonthView.YearLabel.Text), mnthNumber, 1).AddMonths(1).AddDays(-1).Day
    If currentDate.HasValue Then
        newDateTime = New DateTime(CInt(DropDownMonthView.YearLabel.Text), mnthNumber, If(currentDate.Value.Day > lastDayOfMonth, lastDayOfMonth, currentDate.Value.Day))
    Else
        newDateTime = New DateTime(CInt(DropDownMonthView.YearLabel.Text), mnthNumber, If(DateTime.Now.Day > lastDayOfMonth, lastDayOfMonth, DateTime.Now.Day))
    End If

    Get the last day of the current month, if it is after the selected date, use the new lastDayOfMonth.

    All Better.
    Thx
    Theo Jacobs
  4. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 24 Jan 2013 Link to this post

    Hi Theo,

    I have added the correction in the projects in the first post.

    Thank you.
     

    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top