Hi,
I Want to Change the EndDate and Duration, during CalendarInfoChanged event. I Wrote the following Code but its Not Changing. Is it Correct Code ? if Not tell me corret one.
DateTime Endate;
Endate = ultraCalendarInfo1.Tasks[0].Tasks[0].EndDateTime.Date;
Endate = Endate.AddDays(3);
double timspn = Convert.ToDouble(Endate.Subtract(ultraCalendarInfo1.Tasks[0].Tasks[0].StartDateTime.Date).TotalDays);
ultraCalendarInfo1.Tasks[0].Tasks[0].Duration.Add(
TimeSpan.FromDays(timspn));
Thank You
Hello ,
The EndDate and the Duration of a Task have related each other, so if you change EndDate, Duration is calculated automatically and vice versa. So if you want to change Duration of a task it is enough to write
ultraCalendarInfo1.Tasks[0].Tasks[0].Duration = new TimeSpan(…);
(ultraCalendarInfo1.Tasks[0].Tasks[0].Duration.Add(…) comes from TimeSpan class and this method returns a new TimeSpane instance, which is extended with specific interval, it doesn’t add interval to the current instance of the TimeSpan object. For more information please see the next link, please note “Remarks” section: http://msdn.microsoft.com/en-us/library/system.timespan.add%28v=vs.71%29.aspx )
I am not sure if CalendarInfoChanged event is most appropriate event to modify a Task, because this event is fired after any property has changed in the CalendarInfo object, so modification of a Task will leads to firing of the CalendarInfoChanged event, where Task is modifying again. This could cause unexpected behavior of the component.
Please let me know if you have any further questions.