1
Vote

Wrong scroll bar maximum when all day events are shown

description

Reason: The method "AdjustScrollbar()" is not called when the calendar is repainted
Quick fix: Call "AdjustScrollbar()" in "OnPaint(...)" after the control was updated
i.e.:
    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
 
        // resolve appointments on visible date range.
        ResolveAppointmentsEventArgs args = new ResolveAppointmentsEventArgs(this.StartDate, this.StartDate.AddDays(daysToShow));
        ResolveAppointments(args);
 
        using (SolidBrush backBrush = new SolidBrush(renderer.BackColor))
            e.Graphics.FillRectangle(backBrush, this.ClientRectangle);
 
        // Visible Rectangle
        Rectangle rectangle = new Rectangle(0, 0, this.Width - VScrollBarWith, this.Height);
 
        DrawDays(ref e, rectangle);
 
        DrawHourLabels(ref e, rectangle);
 
        DrawDayHeaders(ref e, rectangle);
 
  • AdjustScrollbar(); // ***
    }

comments