This is a migrated thread and some comments may be shown as answers.
Hide Weekend (Sat and Sun) in Winforms RadCalendar
6 Answers 92 Views
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 02 Jul 2008, 10:02 PM

Can someone explain how I can hide Saturday and Sunday columns in the RadCalendar for WinForms?

I have seen a code sample for AJAX, but I can see how to implement the same function in WinForms.

If hiding the columns isn't possible, how about  disabling them??

Thanks in advance for any help.

6 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Jul 2008, 01:20 PM
Hello Tony,

Currently, there is no propery in RadCalendar by which you can automatically hide the columns for the days of the weekend. However, I prepared a sample solution to demonstrate a workaround. You should traverse the CalendarTableElement which contains the CalendarCellElements of interest. Then, for those cellelements which represents days of the weekend, set the Visibility property to Hidden.

If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mike
Top achievements
Rank 1
answered on 15 Sep 2008, 04:39 PM
Tony, sorry for snaking your thread....  

Nikolay, 
    this is great solution for a single calendar, but I cannot figure how to disable weekends for a multimonth view.

Could you possibly expand on the provided workaround to do this?


TIA,
Mike
0
Mike
Top achievements
Rank 1
answered on 15 Sep 2008, 05:39 PM
After some messing with the Element Hierarchy editor i managed to come up with a valid way to handle this for multimonth views.

Below is the code i used. Hope this helps someone else in the future.


private void DisableWeekends()  
{  
    RadCalendarElement calElement = rcalTripDates.RootElement.Children(0) as RadCalendarElement;  
    MultiMonthViewElement calMultiMonthviewElement = calElement.Children(0).Children(2) as MultiMonthViewElement;  
    CalendarMultiMonthViewTableElement calMultiMonthViewTableElement = calMultiMonthviewElement.Children(0).Children(1) as CalendarMultiMonthViewTableElement;  
    foreach (MonthViewElement mvwElement in calMultiMonthViewTableElement.Children) {  
        CalendarTableElement calTable = mvwElement.Children(0).Children(1) as CalendarTableElement;  
        if (!calTable == null)  
        {  
            foreach (CalendarCellElement cell in calTable.Children) {  
                if ((cell.Date.DayOfWeek == DayOfWeek.Saturday) || (cell.Date.DayOfWeek == DayOfWeek.Sunday) || (cell.Text == "S"))  
                {  
                    cell.Enabled = false;  
                }  
            }  
        }  
    }  
0
Boyko Markov
Telerik team
answered on 16 Sep 2008, 09:46 AM
Hello Mike,

I think there is a better way to hide weekend days. CalendarCellElement has a property named WeekEnd. This will allow you to exclude the huge If statement.

 
Regards,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 16 Sep 2008, 12:39 PM
Boyko,

thanks for the info... the huge IF statement is actually from the submitted project that Nikolay posted. I only added the extra nesting for the mutlimonthviews.

I will try the Weekend property and see how that works out.
0
Boyko Markov
Telerik team
answered on 16 Sep 2008, 03:29 PM
Sounds great, Mike. Let me know if I can help you with something else regarding this control.

 
All the best,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Tony
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Mike
Top achievements
Rank 1
Boyko Markov
Telerik team
Share this question
or