Interactive Gantt chart VARCHART XGantt: how to calculate the end date (ActiveX edition)

VARCHART XGantt is an interactive Gantt chart control, and its modular design allows you to create applications that meet your and your customers needs. It can be quickly and easily integrated into your applications, helping you to identify performance bottlenecks, avoid delays and efficient use of resources, making it easier to understand complex data.

This article explains how VARCHART XGantt major computing activities end time, and interested friends can look at their own hands oh ~

Table End Date column remains empty. The help that can be included in the calendar of the VARCHART XGantt, from the " start " and " duration of the event of calculation" field.

In the default calendar, working day (Monday to Friday) is defined as the activity time, and on weekends (Saturday and Sunday) is defined as inactive time.

In the figure, you can identify inactive time by a gray background. By the " nodes " to disable the "property page calendar assigned to the node " option to turn off the calendar.

Please note that the differences in the calculation of whether the calendar:

Activities begin from Friday and last for three days if the calendar is activated, the event will end on Tuesday. No calendar, the event will end on Sunday.

End date through the object AddDuration VcCalendar of (...) method to calculate. Therefore, the start and duration of each activity. They can be retrieved from the corresponding data fields by index. By DataField (...) then set the end date, you must call UpdateNode VcNode the way so you can see changes to the data.

Sample Code

Dim tmpCal As VcCalendar
Dim tmpDate As Date
Set tmpCal = VcGantt1.CalendarCollection.Active
tmpDate = tmpCal.AddDuration(node.DataField(2), node.DataField(4))
node.DataField(3) = tmpDate
node.UpdateNode

Create or modify activities start and end dates are automatically placed in the active time by mouse interaction.

QQ screenshot 20190827144111.png

In contrast, the API or edit dialog and date settings can be placed in non-working hours.

QQ screenshot 20190827144136.png

By calculating the resulting date is always located within working hours. In order to ensure that the date set in the working time API, calculated from the required start date and end date of activity duration.

Sample Code

tmpDate = tmpCal.AddDuration(node.DataField(3), _
 (-1) * node.DataField(4))
node.DataField(2) = tmpDate

In order to maintain the consistency of data, loss or negative duration shall be deemed to be incorrect, and reset to 0. If missing a start date, end date can not be calculated. Summarized the required code named SetNodeEndDate (...) separate methods.

Sample Code

Private Sub SetNodeEndDate(ByVal node As VcNode)
 'Avoid empty or negative duration
 If node.DataField(4) = "" Or node.DataField(4) < 0 Then
 node.DataField(4) = "0"
 End If
 'Start date empty then end date should also be empty
 If node.DataField(2) = "31.12.1899 00:00:00" Then
 node.DataField(3) = ""
 Else
 'Precondition is property page nodes
 '"Assign calendar to nodes" must be true
 Dim tmpCal As VcCalendar
 Dim tmpDate As Date
 Set tmpCal = VcGantt1.CalendarCollection.Active
 tmpDate = tmpCal.AddDuration(node.DataField(2), _
 node.DataField(4))
 node.DataField(3) = tmpDate
 'Start date only in active times
 tmpDate = tmpCal.AddDuration(node.DataField(3), _
 (-1) * node.DataField(4))
 node.DataField(2) = tmpDate
 node.UpdateNode
 End If
End Sub

需要计算日期:

1、活动结束后

2、通过数据编辑对话框或就地编辑器修改日期或持续时间之后

3.、API修改活动值后

然而,在通过鼠标交互进行修改之后,不必启动计算,因为这将自动执行内部计算。

可以通过VcGantt对象的属性NodeCollection来设置包括所有节点的计算循环。它的代码将被添加到事件Form1_Load(...)的末尾。

示例代码

'Calculate end date for all nodes
Dim node As VcNode
For Each node In VcGantt1.NodeCollection
 SetNodeEndDate node
Next

By event OnNodeModifyComplete Change Data Capture user caused. End of the calculation method call execution date.

Sample Code

Private Sub VcGantt1_OnNodeModifyComplete _
 (ByVal node As VcGanttLib.VcNode, _
 ByVal isLastNodeInSeries As Boolean)
 SetNodeEndDate node
End Sub

If the data has been changed through the API, you must call SetNodeEndDate (...) .


Guess you like

Origin blog.51cto.com/14467432/2433142