October 22, 2018, 09:31:22 AM

See more Support incidents in our old archived forum.

Author Topic: How to listen to the gantt chart view's start time changes  (Read 2750 times)

mkk

  • Customers
  • Newbie
  • *
  • Posts: 2
How to listen to the gantt chart view's start time changes
« on: August 11, 2014, 02:33:10 PM »
Hi
 
In my application I have two ComboBoxes, which are being used to set the start and end times for the GanttChart. For this purpose I use some modified code from your sample, which works as expected.
 
Now I want these ComboBoxes to be automatically set  to the LeftMostVisibleTime and the RightMostVisibleTime of the GanttChart (I use FitToPage as standard) when the end user changes anything (zoom in/out scroll etc.) on the GanttGrid and the GanttChart.
 
When the ComboBoxes are changed automatically it most not trigger a restart of the first process (similar to when the user changes the ComboBoxes)
 
Could you advice how I can handle this (various Events and properties)?
 
Thanks!

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 83
Re: How to listen to the gantt chart view's start time changes
« Reply #1 on: August 11, 2014, 02:35:39 PM »
Mark,

You can listen to GanttChart.ViewTimeRangeChanged or GanttChart.ViewportTimeRangeChanged (has to be used if you have horizontal scrolling turned on in the chart - ResizeToFit = false).

When you set your DateTime editor's values, you should turn on a bool flag in your page so that you can distinguish user-edited VS programatically edited scenarios in the rest of your page.

Thanks
Support

mkk

  • Customers
  • Newbie
  • *
  • Posts: 2
Re: How to listen to the gantt chart view's start time changes
« Reply #2 on: August 11, 2014, 04:18:27 PM »

I would also like to know which time properties I should use to get the right start end time of the Gantt Chart when ResizeToFit is set to true and to false.

Thanks!
Michael


Rajagopal

  • RQ Members
  • Jr. Member
  • *
  • Posts: 99
Re: How to listen to the gantt chart view's start time changes
« Reply #3 on: August 13, 2014, 04:29:40 PM »
Mark,

You can use the VisualStartTime and VisualEndTime properties of GanttChart. Here is the sample code,

Code: [Select]
void ganttControl_TemplateApplied(object sender, EventArgs e)
{
    this.ganttControl.GanttChart.AnchorTime = this.ganttControl.ProjectStartDate;
    this.ganttControl.GanttChart.ViewportTimeRangeChanged += GanttChart_ViewportTimeRangeChanged;
}

void GanttChart_ViewportTimeRangeChanged(object sender, EventArgs e)
{
    DateTime visualStart = this.ganttControl.GanttChart.VisualStartTime;
    DateTime visualEnd = this.ganttControl.GanttChart.VisualEndTime;
}