method Items.SchedulePDM (Item as HITEM, Key as Variant)
Schedules the chart using the Precedence Diagram Method.

TypeDescription
Item as HITEM A long expression that specifies the handle of the item where the SchedulePDM starts, or 0, if the Key indicates an unique key of the bar that starts scheduling the SchedulePDM.
Key as Variant A VARIANT expression that specifies the key of the bar where the SchedulePDM begins. If the Item parameter is 0, the chart looks for the first bar with specified key.
ReturnDescription
LongA long expression that specifies whether the operation is successful (0 or any positive value indicating a warning) or failed (negative value).  Possible values are
  • 0, success
  • 1, (warning) no bar provided to SchedulePDM method
  • 2, (warning) single bar in SchedulePDM call
  • 3, (warning) SchedulePDM method is called during the BarResize event (possible a recursive call/stack overflow)
  • 4, (warning) no links between scheduled bars
  • -1, (error) possible cycling
  • -2, (error) can not move the base bar
  • -3, (error) scheduling the A and B bars fails
  • -4, (error) no IN bars
  • -5, (error) base bar is not initialized
  • -6, (error) source bar is not initialized (possible cycling)
  • -7, (error) target bar is not initialized (possible cycling)
  • -8, (error) no TRANSLATION bar
  • -9, (error) bar linked to itself. For instance, a bar linked to its summary bar
The SchedulePDM method arranges the activities on the plan based on the links / relationships / dependencies. The SchedulePDM calculates early and late dates, based on bar's position, link types and link lag. The SchedulePDM starts from the giving bar, and continue arranging related bars, unti all related bars are arranged. If a bar has no related bars (no incoming or outgoing links) the procedure still looking for grouped or summary bars, until it finds relative bars.

Tasks may have multiple predecessors or multiple successors. Before you begin establishing dependencies, itís important to understand that there are four types:

The following screen show shows the chart before calling the SchedulePDM on the Oplata bar:

The following screen show shows the chart after calling the SchedulePDM on the Oplata bar:

The SchedulePDM method handles the following bars:

The type of the link (exLinkType) between two bars is:

The following properties defines the lag of the link (indicates a delay between two activities):

The ChartStartChaning(exPDM) event is fired once the SchedulePDM method is called. The ChartEndChaning(exPDM) event is fired once the SchedulePDM method is called. If Undo/Redo is available, the entire operation is hold as a block, so the chart can be restored by calling the Undo operation, or by pressing the CTRL + Z on chart. You can check the ChartUndoListAction property to lists the actions being performed during the SchedulePDM method. The DefSchedulePDM property defines options to be used by the SchedulePDM method. If required any option to be used the DefSchedulePDM should be called before the SchedulePDM method else it will have no effect. For instance, use the Def SchedulePDM property to specify a start date for the project, so the SchedulePDM method will use it, to arrange all bars so no bars will start before the specified date. The same if you require to specify the end of the project. The SchedulePDM method invokes the BarResize event for all affected bars. 

The following screen shot shows the chart using different type of links before calling the SchedulePDM:

The following screen shot shows the chart using different type of links after calling the SchedulePDM:

and if we move the first bar and call again the SchedulePDM we get ( the sample preserve the working units for each bar ):

The following screen shot shows the activities, when exLinkPDMWorkingDelay property is set for links ( SF has 1 working day, FS has 2 working days and the FF has 3 working days delay ) :

The following snippet of code, ensures that the SchedulePDM method is not called during the BarResize event: (prevent recursive calls).

Dim iSchedulePDM As Long
Private Sub G2antt1_BarResize(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    Debug.Print "BarResize invoked"
    If (iSchedulePDM = 0) Then
        iSchedulePDM = iSchedulePDM + 1
            G2antt1.Items.SchedulePDM Item, Key
        iSchedulePDM = iSchedulePDM - 1
    End If
End Sub

The following approach, prevent recursive calls of SchedulePDM method during the BarResize event:

iPDMRunning = 0

event ChartStartChaning(Operation)
    if ( Operation == exPDM (12) )
        iPDMRunning++

event ChartEndChaning(Operation)
    if ( Operation == exPDM (12) )
        iPDMRunning--

event BarResize(Item,Key)
    if ( iPDMRunning == 0 )
        Call SchedulePDM(Item,Key)

The following VB sample displays a message when the SchedulePDM starts and ends:

Private Sub G2antt1_ChartStartChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM starts"
    End If
End Sub

Private Sub G2antt1_ChartEndChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM ends"
    End If
End Sub