How can i get current view "Month" Data?

6 posts, 0 answers
  1. ZHOU
    ZHOU avatar
    10 posts
    Member since:
    Feb 2014

    Posted 21 Aug 2014 Link to this post

    I was trying to using navigation event, whenever I clicked the navigation button , i was trying to retrieve the current view month.

    Is there any easy way or some properties already exists to get the current view month?

    Thanks.
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 22 Aug 2014 Link to this post

    Hi Zhou Jiang,

    You can get the current view of RadScheduler by accessing its ActiveView property. To get the data range of the view (hence the month) you can access the view's RangeStartDate and RadngeEndDate properties. More information about the scheduler views is available in the following section: http://www.telerik.com/help/winforms/scheduler-views-month-view.html.

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards, Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. ZHOU
    ZHOU avatar
    10 posts
    Member since:
    Feb 2014

    Posted 22 Aug 2014 in reply to Stefan Link to this post

    HI Stefan, 

    Thank you for your reply. I am using Calender control not the scheduler control.

    Is that the same ?

    Thank you.
  5. ZHOU
    ZHOU avatar
    10 posts
    Member since:
    Feb 2014

    Posted 22 Aug 2014 Link to this post

    Another question is whenever i click the navigation button , i would like to refresh the currentView. ( I made some cell backgroud color in the previous month, but now when i click the navigation button , they are still exist).

    How can i refresh the currentVIew. radCalendar.refresh doesnt work.

    Thanks.
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Aug 2014 Link to this post

    Hello Zhou,

    Please excuse me for the mistake. 

    Here is how to get the current view of RadCalendar. A suitable event for capturing changes in the view is the ViewChanged event:
    void radCalendar1_ViewChanged(object sender, EventArgs e)
    {
        MonthViewElement monthViewElement = radCalendar1.CalendarElement.CalendarVisualElement as MonthViewElement;
        Console.WriteLine("StartDate: " + monthViewElement.View.ViewStartDate + " " + "EndDate: " + monthViewElement.View.ViewEndDate);
    }

    As to the cells customization, you did not mention how are you achieving it. However, the correct way to do it is to use the ElementRender event, where you apply the desired modifications for the desired cells and reset them for the rest:
    void radCalendar1_ElementRender(object sender, RenderElementEventArgs e)
    {
        if (e.Day.Date == new DateTime(2014, 9, 25))
        {
            e.Element.DrawFill = true;
            e.Element.BackColor = Color.Yellow;
        }
        else
        {
            e.Element.ResetValue(CalendarCellElement.DrawFillProperty, ValueResetFlags.Local);
            e.Element.ResetValue(CalendarCellElement.BackColorProperty, ValueResetFlags.Local);  
        }
    }

    Off topic, may I please ask you to avoid mixing different questions in the same topic, in order to keep the information in the forum easy to find. You can also have a look at the forum rules: http://www.telerik.com/forums/important-information-on-using-the-telerik-forums-d6b4a5cf7d4e.

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  7. ZHOU
    ZHOU avatar
    10 posts
    Member since:
    Feb 2014

    Posted 27 Aug 2014 Link to this post

    Thank you very much , haven't tested the current view yet, but second one works great. 
Back to Top
UI for WinForms is Visual Studio 2017 Ready