Back to Devexpress

GanttControl.RequestTimescaleRulers Event

windowsforms-devexpress-dot-xtragantt-dot-ganttcontrol-d293d5a4.md

latest3.2 KB
Original Source

GanttControl.RequestTimescaleRulers Event

Fires when the chart is zoomed in / zoomed out. Allows you to customize the timescale rulers.

Namespace : DevExpress.XtraGantt

Assembly : DevExpress.XtraGantt.v25.2.dll

NuGet Package : DevExpress.Win.Gantt

Declaration

csharp
[DXCategory("Events")]
public event RequestTimescaleRulersEventHandler RequestTimescaleRulers
vb
<DXCategory("Events")>
Public Event RequestTimescaleRulers As RequestTimescaleRulersEventHandler

Event Data

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

PropertyDescription
TimescaleRulersProvides access to the chart’s timescale rulers.

The event data class exposes the following methods:

MethodDescription
GetTimescaleUnitWidth(GanttTimescaleUnit)Returns the width of the specified measure unit on the timescale.

Remarks

The timescale can display between one and three rulers. Rulers display different measure units depending on the zoom factor: years-quarters-months, months-days-hours, etc.

Example

The code below shows how to change the date-time format depending on the time scale ruler’s measure unit.

csharp
using DevExpress.XtraGantt;

private void ganttControl1_RequestTimescaleRulers(object sender, DevExpress.XtraGantt.RequestTimescaleRulersEventArgs e) {
    GanttTimescaleRuler ruler0 = e.TimescaleRulers[0];
    if (ruler0.Unit == GanttTimescaleUnit.Month)
        ruler0.DisplayFormat = "MMM yy";
    GanttTimescaleRuler ruler1 = e.TimescaleRulers[1];
    if (ruler1.Unit == GanttTimescaleUnit.Day)
        ruler1.DisplayFormat = "dddd, d";
}
vb
Private Sub ganttControl1_RequestTimescaleRulers(ByVal sender As Object, ByVal e As RequestTimescaleRulersEventArgs) _
    Handles ganttControl1.RequestTimescaleRulers
    Dim ruler0 As GanttTimescaleRuler = e.TimescaleRulers(0)
    If ruler0.Unit = GanttTimescaleUnit.Month Then
        ruler0.DisplayFormat = "MMM yy"
    End If
    Dim ruler1 As GanttTimescaleRuler = e.TimescaleRulers(1)
    If ruler1.Unit = GanttTimescaleUnit.Day Then
        ruler1.DisplayFormat = "dddd, d"
    End If
End Sub

See Also

GanttControl Class

GanttControl Members

DevExpress.XtraGantt Namespace