Need help with selection and blackoutdates in CalendarEdit class

private void setBlackOutDates(DatesCollection datesSelected)

       {

            DateTime date = datesSelected.First<DateTime>();           


            int year = date.Year;

            int month = date.Month;


            BlackoutDatesRange blackOutDays = new BlackoutDatesRange();


            int daysInMonth = DateTime.DaysInMonth(year, month);


            for (int x = 1; x <= daysInMonth; x++)

            {

                if (new DateTime(year, month, x).DayOfWeek == DayOfWeek.Saturday || new DateTime(year, month, x).DayOfWeek == DayOfWeek.Sunday || new DateTime(year, month, x).DayOfWeek == DayOfWeek.Monday)

                {

                    blackOutDays = ????????;

                    pickCalendar.BlackoutDates.Add(blackOutDays);

                }

            }

        }

i don't know what to put for blackoutDays?!? please help


1 Reply

VR Venkateshwaran Ramdoss Syncfusion Team November 3, 2017 05:39 AM UTC

Hi Byron, 
  
Thank you for your update. 
  
We have prepared a sample for your requirement. In this sample, we have used BlackoutDates collection and BlackoutDatesRange. Please make use of the below code example in the below. 
  
Code example[C#] 
  
private void setBlackOutDates(DatesCollection datesSelected) 
       { 
            DateTime date = datesSelected.First<DateTime>();            
            int year = date.Year; 
            int month = date.Month; 
            BlackoutDatesRange blackOutDays = new BlackoutDatesRange(); 
            int daysInMonth = DateTime.DaysInMonth(year, month); 
  
            for (int x = 1; x <= daysInMonth; x++) 
            { 
                if (new DateTime(year, month, x).DayOfWeek == DayOfWeek.Saturday || new DateTime(year, month, x).DayOfWeek == DayOfWeek.Sunday || new DateTime(year, month, x).DayOfWeek == DayOfWeek.Monday) 
                { 
                    blackOutDays = new BlackoutDatesRange() { StartDate = new DateTime(year, month, x), EndDate = new DateTime(year, month, x) }; 
  
                    CalendarEdit.BlackoutDates.Add(blackOutDays); 
                } 
            } 
        } 
  
We have prepared a sample and screenshot for your reference and it can be downloaded from the below link. 
  
  
Screenshot 
  
 
  
Please check the above solution and let us know if it is helpful. 
  
Regards, 
Venkateshwaran V.R. 


Loader.
Up arrow icon