CustomDrawObjectEventArgs.Handled Property

Gets or sets whether an event was handled. If it was handled, the default actions are not required.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v20.1.dll

Declaration

public virtual bool Handled { get; set; }
Public Overridable Property Handled As Boolean

Property Value

Type Description
Boolean

true if default painting isn't required; otherwise, false.

Remarks

The events used to custom paint various elements of a scheduler control fire before the elements are painted in their default manner. If the event parameter's Handled property is set to true within a handler, default painting will not be performed. Otherwise, any custom painting performed within an event handler will be overridden by the scheduler control's standard drawing routines.

You can set the Handled to true, then call the CustomDrawObjectEventArgs.DrawDefault method in the handler code to render the element using the default drawing mechanism, and then paint custom drawings over default graphics.

Examples

The following sample code handles the SchedulerControl.CustomDrawAppointment event to manually paint appointments. The image below shows the result.

CustomDrawAppointment

using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System.Drawing.Drawing2D;
private void schedulerControl1_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e) {
    TimeLineAppointmentViewInfo tlvi = e.ObjectInfo as TimeLineAppointmentViewInfo;
    // This code works only for the Timeline View.
    if(tlvi != null) {
        Rectangle r = e.Bounds;
        r.Offset(3, 3);
        string[] s = tlvi.Appointment.Subject.Split(' ');

        for(int i = 0; i < s.Length; i++) {
            using(var foreBrush = new SolidBrush(colorArray[i]))
                e.Cache.DrawString(s[i], tlvi.Appearance.Font, foreBrush,
r, StringFormat.GenericDefault);
            SizeF shift = e.Cache.CalcTextSize(s[i] + " ", tlvi.Appearance.Font);
            r.X += (int)shift.Width;
        }
        e.Handled = true;
    }
}
See Also