Hi Guys,
I have implemented a Gantt chart in to my VB.NET project ready to show my managers at a meeting before we purchase Infragistics they now want to add to the Gantt chart who each Task is assigned to. here is my code for what i have done, can anyone help me with how I populate this field.
Regards
David
Imports Infragistics.Win.UltraWinGanttView
Imports Infragistics.Win.UltraWinSchedule
Imports Infragistics.Win
Imports Perrite.Module1
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Infragistics.Win.UltraWinEditors
Imports System.Resources
Public Class FrmMangSchdule
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' 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.ConstraintMember = "Constraint"
Me.UltraGanttView1.CalendarInfo = Me.UltraCalendarInfo1
Me.UltraGanttView1.Project = Me.UltraGanttView1.CalendarInfo.Projects(1)
End Sub
Private Function GetSampleData() As DataSet
Dim connetionString As String = ""
Dim connection As SqlConnection
Dim command As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim firstSql As String
connetionString = "Data Source=ukwarapp02;Initial Catalog=DBSYS;User ID=sa;Password=******"
firstSql = "select * from Gantt"
connection = New SqlConnection(connetionString)
connection.Open()
command = New SqlCommand(firstSql, connection)
adapter.SelectCommand = command
adapter.Fill(ds, "Tasks")
adapter.Dispose()
command.Dispose()
connection.Close()
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, "Test", Date.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("Constraint", GetType(Object))
'retrieve first table data
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim _item0 As String = ds.Tables(0).Rows(i).Item(0)
Dim _item1 As Integer = ds.Tables(0).Rows(i).Item(1)
Dim _item2 As String = ds.Tables(0).Rows(i).Item(2)
Dim _item3 As String = ds.Tables(0).Rows(i).Item(3)
Dim _item4 As DateTime = ds.Tables(0).Rows(i).Item(4)
Dim _item6 As String = ds.Tables(0).Rows(i).Item(6)
' Parent Task1
Dim planningTaskid As Guid = Guid.NewGuid()
' Assign values for each Task member
theTasks.Rows.Add(New [Object]() {planningTaskid, projectKey, _item2, _item4, _item6, TaskConstraint.StartNoEarlierThan})
Next
Return theDataSet
End Function
End Class
Hello davidjames1981,
I`m not sure that I understand what you mean with
davidjames1981 said: they now want to add to the Gantt chart who each Task is assigned to
ultraCalendarInfo1.CustomTaskColumns.Add("Assing to", typeof(string), true);
Task1.SetCustomProperty("Assing to","Mr. Number 1"); Task2.SetCustomProperty("Assing to", "Mr. Number 1 000 000"); Please take a look at the atta ched video file for more details and let me know if you have any questions, or if you think that I misunderstood your scenario. Regards
Task1.SetCustomProperty("Assing to","Mr. Number 1");
Task2.SetCustomProperty("Assing to", "Mr. Number 1 000 000");
Please take a look at the atta ched video file for more details and let me know if you have any questions, or if you think that I misunderstood your scenario.
Hi,
Have you been able to resolve your issue ? Did you try my suggestion. Let me know if you have any questions.
I have tried to implement your method but i could not get this to work.
could it because i am using databindings ? here is the code i am using to populate my data.
i only have a few days of the trial left, having said that we will be purchasing in the next week or 2.
thanks again for your help.
mports
Infragistics.Win.UltraWinGanttView
Imports
Infragistics.Win.UltraWinSchedule
Infragistics.Win
Module1
System.Data.SqlClient
System.Collections.Generic
System.ComponentModel
System.Data
System.Drawing
System.Text
System.Windows.Forms
Infragistics.Win.UltraWinEditors
System.Resources
Public
FrmMangSchdule
.Load
.GetSampleData()
Me
)
"ProjectID"
"ProjectKey"
"ProjectName"
"ProjectStartTime"
"TaskName"
"TaskDuration"
"TaskStartTime"
"TaskID"
'Me.UltraCalendarInfo1.DataBindingsForTasks.ParentTaskIdMember = "ParentTaskID"
"Constraint"
.UltraCalendarInfo1
.UltraGanttView1.CalendarInfo.Projects(1)
Sub
DataSet
""
SqlConnection
SqlCommand
SqlDataAdapter
Integer
String
connetionString =
"Data Source=ukwarapp02;Initial Catalog=DBSYS;User ID=sa;Password=mbl1175"
firstSql =
"select * from Gantt"
connection =
(connetionString) connection.Open() command =
command =
(firstSql, connection) adapter.SelectCommand = command adapter.Fill(ds,
adapter.Fill(ds,
) adapter.Dispose() command.Dispose() connection.Close()
()
"projectKey"
) theProjects.Columns.Add(
theProjects.Columns.Add(
))
theProjects.Rows.Add(
.Today})
) theTasks.Columns.Add(
theTasks.Columns.Add(
)) theTasks.Columns.Add(
ds.Tables(0).Rows.Count - 1
= ds.Tables(0).Rows(i).Item(0)
= ds.Tables(0).Rows(i).Item(1)
= ds.Tables(0).Rows(i).Item(2)
= ds.Tables(0).Rows(i).Item(3)
= ds.Tables(0).Rows(i).Item(4)
= ds.Tables(0).Rows(i).Item(6)
.NewGuid()
theTasks.Rows.Add(
.StartNoEarlierThan})
theDataSet
Function
End
Class
HI,
Thanks for attached code, but I couldn`t find where you are using my suggestion from previous post (for us is better if you attach your sample instead of code snipet), so I could not be sure why this suggestion doesn`t work for you. Nevertheless I made sample for you with local database where I`m using this approach. Could you please take a look at the attached sample and video file for more details and let me know if you have any questions.