The following code illustrates how to perform custom drawing on a day cell, taking into consideration whether this cell is selected or not.
private void calendar_Draw(object sender, MindFusion.Scheduling.WinForms.CustomDrawArgs e)
{
if (e.Date == new DateTime(2006, 12, 24) ||
e.Date == new DateTime(2006, 12, 25))
{
if (e.Element == CustomDrawElements.DayHeader)
{
if (calendar1.Selection.Contains(e.Date))
e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
else
e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds);
RectangleF bounds = new RectangleF(
e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
Brush brush = new SolidBrush(e.Style.HeaderTextColor);
Font f = e.Style.HeaderFont;
if (f == null)
f = Font;
StringFormat format = new StringFormat();
// We should check e.Style.HeaderTextAlignment,
// but use centered for simplicity
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString(e.Date.Day.ToString(),
f, brush, bounds, format);
format.Dispose();
brush.Dispose();
}
else if (e.Element == CustomDrawElements.DayContents)
{
if (calendar1.Selection.Contains(e.Date))
e.Graphics.FillRectangle(Brushes.DarkGoldenrod, e.Bounds);
else
e.Graphics.FillRectangle(Brushes.SteelBlue, e.Bounds);
}
}
}
The code draws the dates 24th and 25th of December, so make sure thay are visible within your view.
Meppy