10441 : Detecting the exact datetime of a location.

Question

When I drag a timeitem and drop it into another location, am I able to detect the exact datetime (Start datetime and End Datetime) of the location where the timeitem is to be dropped? I need to get the exact date so that I could identify whether a timeitem is allowed to be placed there. Thank you.

Answer

In the OnTimeItem_Move event you get the orginal time item and you can access it’s Start and Stop. You also get the e.diff value that is the pixel value of the change. You can use the e.diff pixel value to calculate the new value.

To translate between pixel space and date time space use the Gantt.DateScaler.PixelToTime and Gantt.DateScaler.TimeToPixel functions.

If this was a move operation:
theNewValueForStart = Gantt.DateScaler.PixelToTime(e.TimeItem.DrawRect.Left+e.Diff)

 

Leave a Reply