This project has moved and is read-only. For the latest updates, please go here.

Tasks without calculations (VB.NET)

Sep 26, 2015 at 8:35 AM

I'm trying to display tasks, but however I try, the chart ends up in error (red cross over empty chart).

I think it is because I want to only display tasks and I'm trying to set both Task.Start and Task.Duration and setting relations. The logic then fails to calculate a solution and ends in error. But I don't need any logic, those are fixed dates and relations from a schedule, only to be displayed.

Is there a way to turn off calculations?

I'm using a DLL at the moment and for those curious for a VB.NET code:
    Dim pmng As New projectmanager()                           '  Component inicialization
    Dim tChart As New Chart
    Dim IsGanttInit As Boolean = False
    Private Sub InicializeGantt()
        IsGanttInit = True
    End Sub

    Private Sub UpdateGantt()
        If IsGanttInit = False Then Call InicializeGantt()
        Dim stDate As Date = Me.dgw.Rows(0).Cells("StartDate").Value  ' set start date to first date in DataGridView, which is sorted by date, ascending
        If Me.dgw.Rows.Count > 0 Then                          
            pmng.Start = stDate                                ' set project.Start to start date
        End If
        Dim idx As Int16
        For ir = 0 To Me.dgw.Rows.Count - 1                    ' loop through rows of tasks in DataGridView
            Dim dr As DataGridViewRow = Me.dgw.Rows(ir)        ' set datarow to actual row
            Dim iTask As New Task                  ' create a new task
            Dim TaskShift As Int16 = dr.Cells("StartDate").Value.Subtract(pmng.Start).days    ' calculate a shift in days between the start of the chart and the actual date of task
            iTask.Name = "P" & dr.Cells("TaskNo").Value & " - " & dr.Cells("ProcessName").Value
            idx = pmng.Tasks.Count - 1                         ' Remember index of last-added task
            pmng.Add(iTask)                                    ' Add task to project manager
            pmng.SetStart(iTask, Convert.ToInt16(TaskShift))   ' Shifts task to a desired date
            pmng.SetDuration(iTask, 1)                         ' Set duration, so far just 1 day, but to be modified to proper length
            tChart.SetToolTip(iTask, "Task start date: " & dr.Cells("StartDate").Value )  ' set a tooltip
            If ir > 0 Then
                pmng.Relate(CType(pmng.Tasks(idx - 1), Task), iTask)  ' set relation for all the task to a previous (for the moment; to be modified for parallel tasks...)
            End If
        tChart.AllowTaskDragDrop = False  ' read-only chart 
        tChart.AllowDrop = False      ' do not allow drop  
        tChart.Update()           ' update chart
    End Sub