Infragistics.Win.GanttView绑定数据源

2013年1月20日

roject Table

ProjectID ProjectKey ProjectName ProjectStartTime
Guid.NewGuid() projectKey QuarterlyProject DateTime.Today

Task Table

TaskID ProjectKey TaskName TaskStartTime TaskDuration ParentTaskID TaskConstraint TaskPercentComplete AllProperties
planningTaskid projectKey Planning DateTime.Now TimeSpan.FromDays(5) null StartNoEarlierThan null null
Guid.NewGuid() projectKey Prepare Budget DateTime.Now TimeSpan.FromDays(2) planningTaskid StartNoEarlierThan null null
Guid.NewGuid() projectKey Allocate Teams DateTime.Now.AddDays(2) TimeSpan.FromDays(3) planningTaskid StartNoEarlierThan null null
implementationTaskid projectKey Implementation DateTime.Now.AddDays(6) TimeSpan.FromDays(16) null StartNoEarlierThan null null
installationTaskid2 projectKey Installations DateTime.Now.AddDays(6) TimeSpan.FromDays(2) implementationTaskid StartNoEarlierThan 60 null
Guid.NewGuid() projectKey Execution DateTime.Now.AddDays(8) TimeSpan.FromDays(13) implementationTaskid StartNoEarlierThan null null
testingTaskid projectKey Testing DateTime.Now.AddDays(23) TimeSpan.FromDays(20) null StartNoEarlierThan null null
Guid.NewGuid() projectKey TestPhase1 DateTime.Now.AddDays(23) TimeSpan.FromDays(10) testingTaskid StartNoEarlierThan 20 null
Guid.NewGuid() projectKey TestPhase2 DateTime.Now.AddDays(36) TimeSpan.FromDays(9) testingTaskid StartNoEarlierThan null null

 

Imports Infragistics.Win.UltraWinGanttView
Imports Infragistics.Win.UltraWinSchedule
‘ Call the method that creates a DataSet
Dim ds As DataSet = Me.GetSampleData()

‘ Set the BindingContextControl property to reference this form
Me.ultraCalendarInfo1.DataBindingsForTasks.BindingContextControl = Me
Me.ultraCalendarInfo1.DataBindingsForProjects.BindingContextControl = Me

‘ Set the DataBinding members for Projects
Me.ultraCalendarInfo1.DataBindingsForProjects.SetDataBinding(ds, “Projects”)
Me.ultraCalendarInfo1.DataBindingsForProjects.IdMember = “ProjectID”
Me.ultraCalendarInfo1.DataBindingsForProjects.KeyMember = “ProjectKey”
Me.ultraCalendarInfo1.DataBindingsForProjects.NameMember = “ProjectName”
Me.ultraCalendarInfo1.DataBindingsForProjects.StartDateMember = “ProjectStartTime”

‘ Set the DataBinding members for Tasks
Me.ultraCalendarInfo1.DataBindingsForTasks.SetDataBinding(ds, “Tasks”)

‘ Basic Task properties
Me.ultraCalendarInfo1.DataBindingsForTasks.NameMember = “TaskName”
Me.ultraCalendarInfo1.DataBindingsForTasks.DurationMember = “TaskDuration”
Me.ultraCalendarInfo1.DataBindingsForTasks.StartDateTimeMember = “TaskStartTime”
Me.ultraCalendarInfo1.DataBindingsForTasks.IdMember = “TaskID”
Me.ultraCalendarInfo1.DataBindingsForTasks.ProjectKeyMember = “ProjectKey”
Me.ultraCalendarInfo1.DataBindingsForTasks.ParentTaskIdMember = “ParentTaskID”
Me.ultraCalendarInfo1.DataBindingsForTasks.ConstraintMember = “Constraint”
Me.ultraCalendarInfo1.DataBindingsForTasks.PercentCompleteMember = “TaskPercentComplete”
‘All other properties
Me.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.
Me.ultraGanttView1.CalendarInfo = Me.ultraCalendarInfo1
Me.ultraGanttView1.Project = Me.ultraGanttView1.CalendarInfo.Projects(1)

 

Private Function GetSampleData() As DataSet
Dim theDataSet As New DataSet()
Dim projectKey As String = “projectKey”

Dim theProjects As DataTable = theDataSet.Tables.Add(“Projects”)
theProjects.Columns.Add(“ProjectID”)
theProjects.Columns.Add(“ProjectKey”)
theProjects.Columns.Add(“ProjectName”)
theProjects.Columns.Add(“ProjectStartTime”, GetType(DateTime))
‘ Assign values for each Project member
theProjects.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “QuarterlyProject”, DateTime.Today})

Dim theTasks As DataTable = theDataSet.Tables.Add(“Tasks”)
theTasks.Columns.Add(“TaskID”)
theTasks.Columns.Add(“ProjectKey”)
theTasks.Columns.Add(“TaskName”)
theTasks.Columns.Add(“TaskStartTime”, GetType(DateTime))
theTasks.Columns.Add(“TaskDuration”, GetType(TimeSpan))
theTasks.Columns.Add(“ParentTaskID”)
theTasks.Columns.Add(“Constraint”, typeof(object))
theTasks.Columns.Add(“TaskPercentComplete”)
‘The Task properties are all covered by individual members. But we could save space in the database
‘By storing data as binary using AllProperties and not binding the other fields.
theTasks.Columns.Add(“AllProperties”, typeof(Byte[]))

‘ Parent Task1
Dim planningTaskid As Guid = Guid.NewGuid()
‘ Assign values for each Task member
theTasks.Rows.Add(New [Object]() {planningTaskid, projectKey, “Planning”, DateTime.Now, TimeSpan.FromDays(5), Nothing,TaskConstraint.StartNoEarlierThan,Nothing})
‘ Child Task1 of Parent Task1
theTasks.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “Prepare Budget”, DateTime.Now, TimeSpan.FromDays(2), planningTaskid,TaskConstraint.StartNoEarlierThan,100})
‘ Child Task2 of Parent Task1
theTasks.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “Allocate Teams”, DateTime.Now.AddDays(2), TimeSpan.FromDays(3), planningTaskid, TaskConstraint.StartNoEarlierThan, Nothing})

‘ Parent Task2
Dim implementationTaskid As Guid = Guid.NewGuid()
theTasks.Rows.Add(New [Object]() {implementationTaskid, projectKey, “Implementation”, DateTime.Now.AddDays(6), TimeSpan.FromDays(16), Nothing, TaskConstraint.StartNoEarlierThan, Nothing})
Dim installationTaskid2 As Guid = Guid.NewGuid()
‘ Child Task1 of Parent Task2
theTasks.Rows.Add(New [Object]() {installationTaskid2, projectKey, “Installations”, DateTime.Now.AddDays(6), TimeSpan.FromDays(2), implementationTaskid, TaskConstraint.StartNoEarlierThan, 60})
‘ Child Task2 of Parent Task2
theTasks.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “Execution”, DateTime.Now.AddDays(8), TimeSpan.FromDays(13), implementationTaskid,TaskConstraint.StartNoEarlierThan,Nothing})
‘ Parent Task3
Dim testingTaskid As Guid = Guid.NewGuid()
theTasks.Rows.Add(New [Object]() {testingTaskid, projectKey, “Testing”, DateTime.Now.AddDays(23), TimeSpan.FromDays(20), Nothing, TaskConstraint.StartNoEarlierThan,Nothing})

‘ Child Task1 of Parent Task3
theTasks.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “TestPhase1”, DateTime.Now.AddDays(23), TimeSpan.FromDays(10), testingTaskid,TaskConstraint.StartNoEarlierThan,
20})
‘ Child Task2 of Parent Task3
theTasks.Rows.Add(New [Object]() {Guid.NewGuid(), projectKey, “TestPhase2”, DateTime.Now.AddDays(36), TimeSpan.FromDays(9), testingTaskid,TaskConstraint.StartNoEarlierThan,
Nothing})

Return theDataSet
End Function

声明: 本文采用 BY-NC-SA 协议进行授权. 转载请注明转自: Infragistics.Win.GanttView绑定数据源
本文的评论功能被关闭了.