In SelectType=Range mode, the selected dates should be continuous rather than continual
when there is a unselelctable date,How to prohibits the continual selection.
4/4 4/5 4/7 4/8 are invalid dates.
What I need is :
if my mousedown start at 4/1 and stop at 4/4 , the selected collection should be{4/1, 4/2, 4/3 }
if my mousedown start at 4/1 and stop at 4/6 , the selected collection should be{4/1, 4/2, 4/3 }, and 4/6 shouldn't be display with a selected status.
if my mousedown start at 4/1 and stop at 4/19 , the selected collection should be{4/1, 4/2, 4/3 }, and 4/6,4/9~4/19 shouldn't be display with a selected status.
How to do it.
Hello user12341234,
I have been looking into your issue and in order to change the default behavior I can suggest you handle the SelectedDatesChanged event as follows:
private void xamMonthCalendar1_SelectedDatesChanged(object sender, Infragistics.Windows.Editors.Events.SelectedDatesChangedEventArgs e) { for(int i=0;i<xamMonthCalendar1.SelectedDates.Count-1;i++) if (xamMonthCalendar1.SelectedDates[i + 1]- xamMonthCalendar1.SelectedDates[i] > new TimeSpan(1,0,0,0)) { for (int j = i + 1; j < xamMonthCalendar1.SelectedDates.Count;j++ ) xamMonthCalendar1.SelectedDates.RemoveAt(j); break; } }
If you need any additional assistance on this matter, please feel free to ask.
Hi,Elena Ganeva
Thank for your advice.
Now I understand to use [SelectedDatesChanged event ] and [SelectedDates] to realize the function.
I have tried your code, there is a small bug which will get SelectedDates collection correctly only in the way of selecting from left to right.
It doesn't matter.
Now,I can solve my problem with your help.
Thank you again, your reply saves me a lot of time :-)