11126 : Bigger jumps on datescaler scrolling

Question

I would like to change the user scroll step. I want the user to take bigger steps in time when they press the datescaler scrollbuttons. How can I go about that?

Answer

One way to solve that is to implement the OnBeforeScaleOrSpanChange event and change the deault values.

    private void buttonSetUpBiggerJumpOnTimeScroll_Click(object sender, EventArgs e)
    {
      gantt1.DateScaler.OnBeforeScaleOrSpanChange += new BeforeScaleOrSpanChangeEventHandler(DateScaler_OnBeforeScaleOrSpanChange);
    }

    void DateScaler_OnBeforeScaleOrSpanChange(DateScaler dateScaler, BeforeScaleOrSpanChangeArgs e)
    {
      if (e.DateScalerChangeKind==DateScalerChangeKind.userpan)
      {
        TimeSpan defaultjumpsize=e.NewStartTime-gantt1.DateScaler.StartTime;
        // 4 times bigger jumps than default…
        e.NewStartTime = gantt1.DateScaler.StartTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
        e.NewStopTime = gantt1.DateScaler.StopTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
       
      }
    }

Leave a Reply