10522 : Dependencies between gantt items

Question

Can we create dependencies between gantt items using MS Project method by draying a line from predecessor to successor in the gantt chart?

Answer

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Yes

Set the property IphGantX3.StickyMode=smDependency and the next click on a
time item will draw an outline of a link with IphGantX3.DefaultLinkColor and IphGantX3.DefaultLinkStyle.

To actually create the link object you implement the OnDependencyAction event:

Private Sub phGantX1_OnDependencyAction(ByVal theGant As phGantXControl.IphGantX3, ByVal theStartDataEntity As phGantXControl.IphDataEntity_GantTime2, ByVal theTargetDataEntity As phGantXControl.IphDataEntity_GantTime2)

    Dim aLink As IphDataEntity_Link
    Set aLink = theGant.AddLink
   
    aLink.LinkOwner = theStartDataEntity
    aLink.LinkedTo = theTargetDataEntity
    aLink.LinkStyle = tlsMSProject   

End Sub

 

 

10552 : How do I to control the links with delphi

Question

How do I to control the links with the VCL version?

Answer

This is a code snippet showing how to enter the link create mode in Delphi. The link create mode (smDependency) allows the user to click one time item and drag out a link to another time item in order to create the depency link:

procedure TForm1.SpeedButtonLinkClick(Sender: TObject);
begin

  // Enter depenency create mode… Will stay in this mode until link created
  phGant1.StickyMode:=smDependency;
end;

procedure TForm1.phGant1DependencyAction(theFirst,
  theSecond: TphDataEntity_GantTime);
var
  aLink:TphDataEntity_Link;
begin

  // Leave the sticky mode
  phGant1.StickyMode:=smNone;

  aLink:=phGant1.AddLink;
  aLink.LinkOwner:=theFirst;
  aLink.LinkedTo:=theSecond;

  aLink.LinkStyle:=phGant1.DefaultLinkStyle;
  aLink.LinkColor:=phGant1.DefaultLinkColor;
  aLink.LinkPenWidth:=phGant1.DefaultLinkPenWidth;

end;