Skip to main content
A newer version of this page is available. .

SchedulerControl.CustomDrawNavigationButton Event

Enables navigation buttons to be painted manually.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v18.2.dll

Declaration

public event CustomDrawObjectEventHandler CustomDrawNavigationButton

Event Data

The CustomDrawNavigationButton event's data class is CustomDrawObjectEventArgs. The following properties provide information specific to this event:

Property Description
Bounds Returns the bounding rectangle of the drawing area.
Cache Gets an object which specifies the storage for the pens, fonts and brushes. Use it for custom painting in Scheduler Reports.
Graphics Gets an object used for painting.
Handled Gets or sets whether an event was handled. If it was handled, the default actions are not required.
ObjectInfo Gets information on the painted element.

The event data class exposes the following methods:

Method Description
DrawDefault() Renders the element using the default drawing mechanism.

Remarks

The CustomDrawNavigationButton event occurs before a navigation button is painted. The event parameter’s CustomDrawObjectEventArgs.ObjectInfo property provides information sufficient to paint a navigation button.

Example

This code example modifies the caption of the navigation button to display the number of appointments located within the discoverable time interval of a navigation button. This interval is specified by the SchedulerNavigationButtonOptions.AppointmentSearchInterval property. When one or more appointments fall in this interval, the navigation button becomes active and navigates to the nearest appointment. The navigation button is disabled if there are no appointments in that interval.

CustomDrawNavigationButton_New

public static void scheduler_CustomDrawNavigationButton(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
{
    NavigationButtonNext navButton = e.ObjectInfo as NavigationButtonNext;
    SchedulerControl scheduler = sender as SchedulerControl;
    SchedulerStorage storage = scheduler.Storage as SchedulerStorage;
    // Do not count by resources.
    if (scheduler.GroupType != SchedulerGroupType.None) return;

    if (navButton != null && scheduler != null && storage != null)
    {
        // Count appointments within the interval used by the Next navigation button.
        AppointmentBaseCollection apts = scheduler.Storage.Appointments.Items;
        TimeSpan aptSearchInterval = scheduler.OptionsView.NavigationButtons.AppointmentSearchInterval;
        DateTime lastVisibleTime = scheduler.ActiveView.GetVisibleIntervals().Last().End;
        int aptCount = apts.Where(a => (a.Start > lastVisibleTime) && (a.Start < lastVisibleTime.Add(aptSearchInterval))).Count();
        navButton.DisplayTextItem.Text = String.Format("Next {0} appointments", aptCount);
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawNavigationButton event.

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.

See Also