Back to Devexpress

How to: Extend the DateNavigator Selection by Days, not by Weeks

windowsforms-17585-controls-and-libraries-scheduler-examples-datenavigator-how-to-extend-the-datenavigator-selection-by-days-not-by-weeks.md

latest1.4 KB
Original Source

How to: Extend the DateNavigator Selection by Days, not by Weeks

  • Nov 13, 2018

This example illustrates how you can modify the behavior of the Date Navigator control by creating a class descendant and overriding the required properties. The DateNavigator descendant allows selecting more than seven dates by days, not by weeks, which is the default behavior.

csharp
public class MyDateNavigator : DateNavigator
{
    protected override DateTime AdjustSelectionEnd(DateTime start, DateTime end)
    {
        return end;
        //return base.AdjustSelectionEnd(start, end);
    }

    protected override DateTime AdjustSelectionStart(DateTime start, DateTime end)
    {
        return start;
        //return base.AdjustSelectionStart(start, end);
    }
}
vb
Public Class MyDateNavigator
    Inherits DateNavigator

    Protected Overrides Function AdjustSelectionEnd(ByVal start As Date, ByVal [end] As Date) As Date
        Return [end]
        'return base.AdjustSelectionEnd(start, end);
    End Function

    Protected Overrides Function AdjustSelectionStart(ByVal start As Date, ByVal [end] As Date) As Date
        Return start
        'return base.AdjustSelectionStart(start, end);
    End Function
End Class