Hi,
I am getting an exception when I am using passing an indented task into the TaskDialog and I'm not sure why. In the code below, I am handling the TaskDialogDisplaying event, and inferring whether the task is an exposition, a phase, or a task based on how far it's indented. If it's not indented, it opens the TaskDialog correctly. If it is indented at all, I get the exception. Why are ultraGanttView.ActiveTasks & ultraGanttView.Tasks different for unindented and indented tasks?
Thanks,
Myca
namespace GanttChart.ViewModel
{
public partial class BindingGanttView : Form
#region Constructor
public BindingGanttView()
InitializeComponent();
}
#endregion
#region Private Methods
#region Form Load Event
private void BindingGanttView_Load(object sender, EventArgs e)
// 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(ExpositionRepository.Instance, "ShowPlans");
this.ultraCalendarInfo1.DataBindingsForTasks.SetDataBinding(ExpositionRepository.Instance, "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";
// Since we are showing a task that belongs to an explicitly defined
// project (i.e., not the UnassignedProject), assign that project to
// the control's Project property so the control knows to display that project.
this.ultraGanttView1.CalendarInfo = new UltraCalendarInfo();
this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects.Add("MAMdb", DateTime.Now);
this.ultraGanttView1.GridAreaWidth = 400;
#region //Event Handlers
public void ultraGanttView1_TaskDialogDisplaying(object sender, Infragistics.Win.UltraWinGanttView.TaskDialogDisplayingEventArgs e)
if (e.Task != null)
// The following infers whether a task is a Exposition, a phase, or a basic task based on whether it is indented under it's parent task
if (e.Task.Parent == null) // entry is a Exposition because it has no parent task and is not indented
openDialogExpositionEntry();
else if (e.Task.Parent.Parent == null) //entry is a phase because it has just one parent and no grandparents (1 indent)
openDialogPhaseEntry();
else //entry is a task because it has parents and grandparents (2 indents)
openDialogTaskEntry();
#endregion //Event Handlers
#region //Data entry forms
private void openDialogExpositionEntry()
// There is no additional data to define Expositions, so the default Infragistics form is sufficient
TaskDialog infragisticsDialog = new TaskDialog(ultraGanttView1.ActiveTask, ultraGanttView1.CalendarInfo.Tasks, ultraGanttView1);
infragisticsDialog.Name = "Exposition Entry";
private void openDialogPhaseEntry()
UltraComboEditor phaseType = new UltraComboEditor();
//(infragisticsDialog.Controls[0] as UltraTabControl).Tabs.["General"].TabPage.Controls.Add(phaseType);
infragisticsDialog.Controls.Add(phaseType);
private void openDialogTaskEntry()
#endregion //Data entry forms
Hi Dimitar,
Yes, that appeared to have been the problem. Thank you for your rapid response.
Hello Myca,
I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
Hi Myca,
Thank you for contacting Infragistics Developer Support.
This error appears when you have passed a wrong collection for the parent tasks collection. For the root tasks it is always null so the code doesn’t check it and for the indented tasks the code checks it and throws an error if it is different. In your case you are passing the whole Tasks collection for the calendar info. What you could do is to pass e.Task.Parent.Tasks. This will return the proper collection and no exception would be thrown.
I have attached a sample demonstrating this approach.
Please let me know if you have any additional questions.