Skip to content

DevExpress-Examples/winforms-scheduler-custom-draw-appointments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Scheduler - Customize the appearance of appointments

This example demonstrates the following techniques to customize the appearance of appointments:

  • HTML-inspired Text Formatting

    Random r = new Random();
    private void schedulerControl1_InitAppointmentDisplayText(object sender, AppointmentDisplayTextEventArgs e) {
        string[] stringArray = e.Text.Split(' ');
        StringBuilder builder = new StringBuilder();
        foreach(string str in stringArray)
            builder.Append(string.Concat("<color=", r.Next(0, 255), ",", r.Next(0, 255), ",", r.Next(0, 255), ">", str, " ", "</color>"));
        e.Text = builder.ToString();
    }
  • Custom Draw Appointments The CustomDrawAppointmentBackground event is handled to draw the border and invert the background color for selected appointments. In the Timeline View the subject is painted with different colors.

    private void schedulerControl1_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e) {
        AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;
        if(aptViewInfo == null)
            return;
        if(aptViewInfo.Selected) {
            Rectangle r = e.Bounds;
            Brush brRect = aptViewInfo.Status.GetBrush();
            e.Cache.FillRectangle(brRect, r);
            e.Cache.DrawRectangle(Pens.Blue, r);
            e.Handled = true;
        }
    }

The following screenshot shows the result:

WinForms Scheduler - Customize the appearance of appointments