This is a migrated thread and some comments may be shown as answers.

How can i get current view "Month" Data?

5 Answers 194 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
ZHOU
Top achievements
Rank 2
ZHOU asked on 22 Aug 2014, 04:18 AM
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.

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Aug 2014, 11:10 AM
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.
 
0
ZHOU
Top achievements
Rank 2
answered on 22 Aug 2014, 02:22 PM
HI Stefan, 

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

Is that the same ?

Thank you.
0
ZHOU
Top achievements
Rank 2
answered on 22 Aug 2014, 04:23 PM
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.
0
Stefan
Telerik team
answered on 26 Aug 2014, 08:55 AM
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.
 
0
ZHOU
Top achievements
Rank 2
answered on 27 Aug 2014, 03:21 PM
Thank you very much , haven't tested the current view yet, but second one works great. 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
ZHOU
Top achievements
Rank 2
Answers by
Stefan
Telerik team
ZHOU
Top achievements
Rank 2
Share this question
or