10471 : Scrolling faster

Question

Instead of panning left and right a little bit at a time, I want one click on the pan buttons to move forward the distance X where X = gantt.datescaler.stop – gantt.datescaler.start.
In other words, if your current zoom level is showing 2 days, I want a click on one of those buttons to move forward another two days.

Thanks!

Answer

Go like this:


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

    }
    
    private void DateScaler_OnBeforeScaleOrSpanChange(DateScaler dateScaler, BeforeScaleOrSpanChangeArgs e)
    {
      if (!e.IsZoom)
      {
        TimeSpan jumptime=dateScaler.StopTime.Subtract(dateScaler.StartTime);
        if (e.NewStartTime<dateScaler.StartTime)
        {
          e.NewStartTime=dateScaler.StartTime.Subtract(jumptime);
          e.NewStopTime=dateScaler.StopTime.Subtract(jumptime);
        }
        else
        {
          e.NewStartTime=dateScaler.StartTime.Add(jumptime);
          e.NewStopTime=dateScaler.StopTime.Add(jumptime);
        
        }
      }
    }

Leave a Reply