1
Vote

Fix for selection not showing when selection extends above the header

description

Change the first few lines of Calendar.DayView DrawDay method to
 
    private void DrawDay(ref PaintEventArgs e, Rectangle rect, DateTime time)
    {
        Rectangle workingHoursRectangle = GetHourRangeRectangle(workStart, workEnd, rect);
 
        if (workingHoursRectangle.Y < this.HeaderHeight)
        {
            // Fix : http://www.codeproject.com/cs/miscctrl/Calendardayview.asp?forumid=232232&select=1904152&df=100#xx1904152xx

            workingHoursRectangle.Height -= this.HeaderHeight - workingHoursRectangle.Y;
            workingHoursRectangle.Y = this.HeaderHeight;
        }
 
        if (time.DayOfWeek != DayOfWeek.Saturday && time.DayOfWeek != DayOfWeek.Sunday) //weekends off -> no working hours
            renderer.DrawHourRange(e.Graphics, workingHoursRectangle, false, false);
 
        if ((selection == SelectionType.DateRange) && (time.Day == selectionStart.Day))
        {
            Rectangle selectionRectangle = GetHourRangeRectangle(selectionStart, selectionEnd, rect);
 
            // Fix Start
            if (selectionRectangle.Top < this.HeaderHeight) 
            {
                selectionRectangle.Height -= this.HeaderHeight - selectionRectangle.Y;
                selectionRectangle.Y = this.HeaderHeight;
            }
 
            if (selectionRectangle.Height > 0)
                renderer.DrawHourRange(e.Graphics, selectionRectangle, false, true);
            // Fix End
        }

comments