Skip to main content Skip to footer

Print a Horizontal Cell Border on NonWorking Days in C1GanttView

Background:

How to print a Horizontal Cell Border on NonWorking Days in C1GanttView.

Steps to Complete:

When setting the cell border color by CellBorderColor property, the horizontal lines will not be shown on the non-working days (By default Saturday/Sunday + CalendarExceptions)

To show Horizontal lines on non-working Days as set by CellBorderColor property of GanttView, handle the PaintDay event of GanttView as given below:

private void C1GanttView1_PaintDay(object sender, C1.Win.C1GanttView.PaintDayEventArgs e)
{
  if (e.Date.DayOfWeek == DayOfWeek.Saturday)
 {
   Rectangle rc = new Rectangle(e.Rectangle.X + 1, e.Rectangle.Y, e.Rectangle.Width - 2, 1);
   e.Graphics.DrawRectangle(new Pen(Color.Red, 2), rc);
  }
  if (e.Date.DayOfWeek == DayOfWeek.Sunday)
  {
   Rectangle rc = new Rectangle(e.Rectangle.X + 1, e.Rectangle.Y, e.Rectangle.Width - 2, 1);
   e.Graphics.DrawRectangle(new Pen(Color.Red, 2), rc);
   }
   else
   {
    bool isException = false;
    int temp = c1GanttView1.CalendarExceptions.Where(x => x.StartDate == e.DateTime.Date).Count();
    if (temp > 0)
     {
       isException = true;
      }
    if (isException)
   {
    Rectangle rc = new Rectangle(e.Rectangle.X+1, e.Rectangle.Y, e.Rectangle.Width-2, 1);
    e.Graphics.DrawRectangle(new Pen(Color.Red, 2), rc);
    }
 } 
}

Prabhat Sharma