Back to Devexpress

CustomDrawObjectEventArgs.ObjectInfo Property

windowsforms-devexpress-dot-xtrascheduler-dot-customdrawobjecteventargs-e65e0b85.md

latest8.0 KB
Original Source

CustomDrawObjectEventArgs.ObjectInfo Property

Gets information on the painted element.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public ObjectInfoArgs ObjectInfo { get; }
vb
Public ReadOnly Property ObjectInfo As ObjectInfoArgs

Property Value

TypeDescription
DevExpress.Utils.Drawing.ObjectInfoArgs

A DevExpress.Utils.Drawing.ObjectInfoArgs class which provides information on the painted element.

|

Remarks

Use the ObjectInfo property to obtain the painted element’s settings and perform custom painting based upon these settings.

Example

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

View Example

csharp
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;
    }
}
vb
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Drawing
Imports System.Drawing.Drawing2D
Private Sub schedulerControl1_CustomDrawAppointment(ByVal sender As Object, ByVal e As CustomDrawObjectEventArgs) Handles schedulerControl1.CustomDrawAppointment
    Dim tlvi As TimeLineAppointmentViewInfo = TryCast(e.ObjectInfo, TimeLineAppointmentViewInfo)
    ' This code works only for the Timeline View.
    If tlvi IsNot Nothing Then
        Dim r As Rectangle = e.Bounds
        r.Offset(3, 3)
        Dim s() As String = tlvi.Appointment.Subject.Split(" "c)

        For i As Integer = 0 To s.Length - 1
            Using foreBrush = New SolidBrush(colorArray(i))
                e.Cache.DrawString(s(i), tlvi.Appearance.Font, foreBrush, r, StringFormat.GenericDefault)
            End Using
            Dim shift As SizeF = e.Cache.CalcTextSize(s(i) & " ", tlvi.Appearance.Font)
            r.X += CInt(shift.Width)
        Next i
        e.Handled = True
    End If
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ObjectInfo property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-scheduler-customize-appointment-flyout/CS/CustomAppointmentFlyoutExample/Form1.cs#L46

csharp
void CustomDrawAppointmentFlyoutSubject(CustomDrawAppointmentFlyoutSubjectEventArgs e) {
    AppointmentBandDrawerViewInfoBase viewInfo = (AppointmentBandDrawerViewInfoBase)e.ObjectInfo;
    e.DrawBackgroundDefault();

winforms-scheduler-country-specific-work-week-holidays/CS/Form1.cs#L66

csharp
// Check whether the current object is a Day Header.
SchedulerHeader header = e.ObjectInfo as SchedulerHeader;
if (header != null) {

winforms-scheduler-custom-draw-appointments/CS/CustomDrawDemo/Form1.cs#L133

csharp
private void schedulerControl1_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e) {
    AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;
    if(aptViewInfo == null)

winforms-scheduler-resolve-appointment-conflicts/CS/DXApplication1/Form1.cs#L66

csharp
SchedulerControl scheduler = sender as SchedulerControl;
AppointmentViewInfo viewInfo = (e.ObjectInfo as DevExpress.XtraScheduler.Drawing.AppointmentViewInfo);
Appointment apt = viewInfo.Appointment;

winforms-scheduler-customize-appointment-flyout/VB/CustomAppointmentFlyoutExample/Form1.vb#L50

vb
Private Sub CustomDrawAppointmentFlyoutSubject(ByVal e As CustomDrawAppointmentFlyoutSubjectEventArgs)
    Dim viewInfo As AppointmentBandDrawerViewInfoBase = CType(e.ObjectInfo, AppointmentBandDrawerViewInfoBase)
    e.DrawBackgroundDefault()

winforms-scheduler-country-specific-work-week-holidays/VB/Form1.vb#L52

vb
' Check whether the current object is a Day Header.
Dim header As SchedulerHeader = TryCast(e.ObjectInfo, SchedulerHeader)
If header IsNot Nothing Then

winforms-scheduler-custom-draw-appointments/VB/CustomDrawDemo/Form1.vb#L133

vb
Private Sub schedulerControl1_CustomDrawAppointmentBackground(ByVal sender As Object, ByVal e As CustomDrawObjectEventArgs) Handles schedulerControl1.CustomDrawAppointmentBackground
    Dim aptViewInfo As DevExpress.XtraScheduler.Drawing.AppointmentViewInfo = TryCast(e.ObjectInfo, DevExpress.XtraScheduler.Drawing.AppointmentViewInfo)
    If aptViewInfo Is Nothing Then

winforms-scheduler-resolve-appointment-conflicts/VB/DXApplication1/Form1.vb#L55

vb
Dim scheduler As SchedulerControl = TryCast(sender, SchedulerControl)
Dim viewInfo As AppointmentViewInfo = TryCast(e.ObjectInfo, DevExpress.XtraScheduler.Drawing.AppointmentViewInfo)
Dim apt As Appointment = viewInfo.Appointment

See Also

CustomDrawObjectEventArgs Class

CustomDrawObjectEventArgs Members

DevExpress.XtraScheduler Namespace