Query |
Response |
I would like to have icons appear on the monthly view to indicate certain events rather than shortened text describing the event. Is that possible? |
By default, ScheduleControl does not have the direct support to load the image for specific events. But, You could achieve your reported scenario by handling the DrawCellDisplayText event. Please refer the following code example and the sample.
C#
this.scheduleControl1.GetScheduleHost().DrawCellDisplayText += Form1_DrawCellDisplayText;
void Form1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e)
{
if (e.Style.CellValue.ToString().Contains("subject"))
{
string date = e.Style.CellValue.ToString().Substring(0, e.Style.CellValue.ToString().IndexOf("\n"));
DateTime dateTime;
if (e.RowIndex == 1 && e.ColIndex == 1)
{
dateTime = DateTime.ParseExact(date, this.scheduleControl1.Appearance.WeekMonthNewMonth, this.scheduleControl1.Culture).Date;
}
else
{
dateTime = DateTime.Parse(date, this.scheduleControl1.Culture).Date;
}
IScheduleAppointmentList list = this.scheduleControl1.DataSource.GetSchedule(dateTime, dateTime);
Color c = ((ListObject)scheduleProvider.GetLabels()[4]).ColorMember;
Rectangle rect = e.TextRectangle;
Rectangle eventRect = new Rectangle(rect.X + 6, rect.Y + 22, e.ClipBounds.Width, 27);
foreach (IScheduleAppointment item in list)
{
c = ((ListObject)scheduleProvider.GetLabels()[item.LabelValue]).ColorMember;
if (dateTime.Date == DateTime.Now.Date)
{
Bitmap bmp = SystemIcons.Application.ToBitmap();
Size size = new Size(bmp.Width, eventRect.Height);
Bitmap img = new Bitmap(bmp, size);
e.Graphics.FillRectangle(new SolidBrush(c), eventRect);
e.Graphics.DrawImage(img, eventRect.Location);
}
else
{
e.Graphics.FillRectangle(new SolidBrush(c), eventRect);
e.Graphics.DrawString(item.Subject, e.Style.GdipFont, new SolidBrush(e.Style.TextColor), new Point(eventRect.X + 2, eventRect.Y + 12));
}
eventRect.Y += eventRect.Height + 7;
}
}
}
Please refer the following KB link,
|
Also, let's say I have some kind of event that I want to show up as a particular color on the calendar. How can I do that? Is there a document that describes the full api! ? |
To customize the events color, you could implement the custom ScheduleDataProvider and override the InitLists and Getlabels method . Please refer the following kb link,
|