2
Vote

Monthview > Can't effectively Syntactically Set SelectionStart or SelectionEnd

description

in the Monthview control, you cannot syntactically set the SelectionStart or SelectionEnd accurately if you have MaxSelectionCount set.
 
If the default selected date is DateTime.MinValue (or any other value realistically) And have MaxSelectionCount (let's say = 7 for example)
then when you
 
month.SelectionStart = DateTime.Today;
month.SelectionEnd = DateTime.Today.AddDays(5);
 
it will not work if the SelectionStart date is more than 7 days from the current selection.
You can get around this by temporarily changing the MaxSelectionCount to 0, but that is not effective.
 
 
I suggest adding in a
 
    public bool SetSelectionRange(DateTime selectionStart, DateTime selectionEnd)
    {
        if (MaxSelectionCount > 0)
        {
            if (Math.Abs(selectionStart.Subtract(selectionEnd).TotalDays) >= MaxSelectionCount)
            {
                return false;
            }
        }
 
        _selectionStart = selectionStart;
        _selectionEnd = selectionEnd.Date.Add(new TimeSpan(23, 59, 59));
        Invalidate();
        OnSelectionChanged(EventArgs.Empty);
        return true;
    }
 
to set both the start and end at the same time.

comments