Hello,
I am populating the Gantt Chart with a data bus and I have managed to get data published to the chart, but I need the TaskAdded event to fire and it is not firing. I'm not sure why.
My binding class sets all the bindings in the load event, like this:
// Set the BindingContextControl property to reference this form this.ultraCalendarInfo1.DataBindingsForTasks.BindingContextControl = this; this.ultraCalendarInfo1.DataBindingsForProjects.BindingContextControl = this; // Set the DataSource and DataMember for Project and Tasks using the SetDataBinding method this.ultraCalendarInfo1.DataBindingsForProjects.SetDataBinding(MissionRepository.Instance.PlanRepo, "Plans"); this.ultraCalendarInfo1.DataBindingsForTasks.SetDataBinding(MissionRepository.Instance.PlanRepo, "Tasks"); // Set the DataBinding members for Projects this.ultraCalendarInfo1.DataBindingsForProjects.IdMember = "PlanGuid"; this.ultraCalendarInfo1.DataBindingsForProjects.KeyMember = "PlanID"; this.ultraCalendarInfo1.DataBindingsForProjects.NameMember = "PlanName"; this.ultraCalendarInfo1.DataBindingsForProjects.StartDateMember = "PlanStartTime"; // Set the DataBinding members for Tasks // Basic Task properties this.ultraCalendarInfo1.DataBindingsForTasks.NameMember = "TaskName"; this.ultraCalendarInfo1.DataBindingsForTasks.DurationMember = "TaskDuration"; this.ultraCalendarInfo1.DataBindingsForTasks.StartDateTimeMember = "TaskStartTime"; this.ultraCalendarInfo1.DataBindingsForTasks.IdMember = "TaskGuid"; this.ultraCalendarInfo1.DataBindingsForTasks.ProjectKeyMember = "PlanID"; this.ultraCalendarInfo1.DataBindingsForTasks.ParentTaskIdMember = "ParentTaskGuid"; this.ultraCalendarInfo1.DataBindingsForTasks.PercentCompleteMember = "TaskPercentComplete"; // All other properties this.ultraCalendarInfo1.DataBindingsForTasks.AllPropertiesMember = "AllProperties"; this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfo1; Project project = new Project(); project.Key = MissionRepository.Instance.defaultProjectName; project.Name = MissionRepository.Instance.defaultProjectName; project.StartDate = DateTime.Now; this.ultraCalendarInfo1.Projects.Add(project); this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[1]; this.ultraGanttView1.CreationFilter = new CurrentDayIndicatorCreationFilter(); this.ultraGanttView1.GridAreaWidth = 400;
The binding's Designer code activates the TaskAdded handler:
this.ultraGanttView1.TaskAdded += new Infragistics.Win.UltraWinGanttView.TaskAddedHandler(this.ultraGanttView1_TaskAdded);
I see the new data on the gantt view, but the code never stops at the TaskAdded event. Any ideas on why this is happening?
Thanks,
Myca
Hello Myca,
Thank you for the provided code snipped.
The reason why the TaskAdded event is not fired is because it only fires after the user adds a task. In your scenario the tasks are taken from a data source and thus the event could not be fired. What I could recommend to you for your scenario is to use the TaskDataInitialized event that occurs when a task instance is created via data binding. It fires after every task taken from the data source.
To see how the TaskDataInitialized event works I’ve implemented a simple sample, and you could run and evaluate it, please see attached zip.
I hope that this will help you.
Please do not hesitate to contact me if you have any further question.
Thank you Atanas. I was able to get the TaskDataInitialized event to fire in my code. But I'm wondering if I'm on the wrong path in the way I am using it. I am entering my tasks, and even though I am setting the ParentTaskGuid column, and that is bound to the ParentTaskIDMember in ultraCalendarInfo, I am not seeing child tasks indented. I thought I might have to do it manually with this TaskDataInitialized, but calling e.Task.Indent() from there doesn't seem to have an effect either. Is the chart supposed to interpret the parent IDs to automatically indent? For what it's worth, the parent is always parsed before the child, and the parent ID is always set in the child.