Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 3.12 KB

File metadata and controls

51 lines (43 loc) · 3.12 KB

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

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)