I have created a vb.net application for work and I want to use the Ganttview in this project. to start i simply want to get the data from SQL and place it on the chart. i only want at this stage 3 bits on information.
Job / Startdate /Duration. here is my code . can anyone please help as i really want to buy and use this product.
thanks inadvance.
----------------------------------------------------------------------------------------
Imports Infragistics.Win.UltraWinGanttView
Imports Infragistics.Win.UltraWinSchedule
Imports System.Data.SqlClient
Public Class Form1
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 = getdata()
' Set the BindingContextControl property to reference this form
Me.UltraCalendarInfo1.DataBindingsForTasks.BindingContextControl = Me
' Set the DataBinding members for Tasks
Me.UltraCalendarInfo1.DataBindingsForTasks.SetDataBinding(ds, "Gantt")
' Basic Task properties
Me.UltraCalendarInfo1.DataBindingsForTasks.NameMember = "Job"
Me.UltraCalendarInfo1.DataBindingsForTasks.DurationMember = "Days"
Me.UltraCalendarInfo1.DataBindingsForTasks.StartDateTimeMember = "StartDate"
Me.UltraGanttView1.CalendarInfo = Me.UltraCalendarInfo1
End Sub
Private Function getdata()
Dim connetionString As String
Dim connection As SqlConnection
Dim command As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
connetionString = "Data Source=ukwarapp02;Initial Catalog=DBSYS;User ID=sa;Password=mbl1175"
sql = "select * from Gannt"
connection = New SqlConnection(connetionString)
Try
connection.Open()
command = New SqlCommand(sql, connection)
adapter.SelectCommand = command
adapter.Fill(ds, "Gantt)
adapter.Dispose()
command.Dispose()
connection.Close()
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
Return ds
End Function
End Class
Hello ,
Thank you for the provided code snipped.
Could you please let me know what is the symptom of your issue, based on your code snipped it seems to me that GanttView doesn’t show anything, because you have missed to set Project for GanttView:
Me.ultraGanttView1.Project = Me.ultraGanttView1.CalendarInfo.Projects(1)
and if you want to use Binding features you should has a project on which your task belongs. On the following link you could find a tutorial how to bind UltraGanttView:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.1/CLR2.0/html/WinGanttView_DataBinding_Support_for_WinGanttView.html
I ma waiting for you feedback.
thank you for your help with this issue. i managed to plot tasks after messing around all day.
now I have put task on the plan all the task start on the same date (today) and not the "TaskStartTime" as i have told it to do. here is the code i am put together, i am sure i am not doing this right but any help would be fantastic. My company are willing to buy this product if i can prove it will do what i want.
Imports Infragistics.Win
Imports Perrite.Module1
Dim ds As DataSet = Me.GetSampleData()
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"
Me.UltraCalendarInfo1.DataBindingsForTasks.SetDataBinding(ds, "Tasks")
Me.UltraCalendarInfo1.DataBindingsForTasks.NameMember = "TaskName"
Me.UltraCalendarInfo1.DataBindingsForTasks.DurationMember = "TaskDuration"
Me.UltraCalendarInfo1.DataBindingsForTasks.StartDateTimeMember = "TaskStartTime"
Me.UltraCalendarInfo1.DataBindingsForTasks.ProjectKeyMember = "ProjectKey"
Me.UltraGanttView1.Project = Me.UltraGanttView1.CalendarInfo.Projects(1)
Private Function GetSampleData() As DataSet
Dim connetionString As String = ""
Dim i As Integer
Dim firstSql As String
firstSql = "select * from Gantt"
command = New SqlCommand(firstSql, connection)
adapter.Fill(ds, "Tasks")
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")
'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})
Next
Return theDataSet
Your task begin at the start date of the project, because you weren’t set binding for Constraint property for Task and UltraCalendar info set DefaultValue for this property AsSoonAsPossible - Schedules the task to start as early as it can. The ConstraintDateTime is not used. If the task on which the constraint is being set is linked to other tasks, a date is used that will not create a conflict with any of the dependent tasks. If the task is not a predecessor, the start date of the associated Project determines the effective constraining date, i.e., the task will begin on the same date as the project. A TaskDependency never conflicts with the 'AsSoonAsPossible' constraint since the constraining date is determined in that case by the dependency. More information about TaskConstraint enumerator you could find on the following link:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/Infragistics2.Win.UltraWinSchedule.v11.1~Infragistics.Win.UltraWinSchedule.TaskConstraint.html
Also I have created a small sample, which demonstrate data binding of UltraCalendarInfo. Please run the sample and let me know if this is what you are looking for.
Please let me know if you have any further questions
thank you so much for you help.
I have now managed to plot all the data, thank you once again for your help.
Regards
David