10854 : Ive got a problem with the AddText of the TextCollection in VCL.

Question

I’ve got a problem with the ‘AddText’ of the ‘TextCollection’.

For exemple after an ‘AddText’ method when i test the ‘TextCollection.Count’ it’s said 0.
I don’t know how to change the text of my ‘TphDataEntity_GantTime’ after i create it.

Answer

The code below adds a text to a time item, and then changes it…

procedure TForm1.Button4Click(Sender: TObject);
begin
  if Assigned(phGant1.ActiveDataEntity) then
  begin
    phGant1.ActiveDataEntity.TextCollection.AddText(‘Hello’,0,0);
    ShowMessage(IntToStr(phGant1.ActiveDataEntity.TextCollection.Count));
    phGant1.ActiveDataEntity.TextCollection.Text[0].Text:=phGant1.ActiveDataEntity.TextCollection.Text[0].Text+’+’;
  end;
end;

10737 : How do I add Time items to the phGant in VCL when UseGridNotTree is true?

Question

How do I add Time items to the phGant in VCL when UseGridNotTree is true?

Answer

There are several samples in the general download that shows this.

For example the sample/VCL/Native/Project1 does it like this:

  phGant1.DateScaler.LookAndFeel:=tlfBoxed;
  phGant1.DateScaler.ScrollButtons:=tsbSmall;
  phGant1.UseGridNotTree:=TRUE;

procedure TForm1.Addrow1Click(Sender: TObject);
var
  aGridTreeNode:TphDataEntity_GridTreeNode;
  aCell:TBabCell;
begin

  if Assigned(phGant1.ActiveGantRow) then
    aGridTreeNode:=phGant1.GridNode_Add(phGant1.ActiveGantRow.GridTreeNode)
  else
    aGridTreeNode:=phGant1.GridNode_Add(nil);

  aCell:=phGant1.Grid.Cell[0,aGridTreeNode.AxisContentItem.ListIndex];
  phGant1.Grid.SetText(aCell,’a new row’);

end;

procedure TForm1.Addtimeitem1Click(Sender: TObject);
var
  aTimeItem:TphDataEntity_Ganttime;
begin
  if Assigned(phGant1.Grid.FocusedCell) then
  begin
    aTimeItem:=phGant1.GridNode_AddGantTime(phGant1.Grid.AxisContentItemToGridTreeNode(phGant1.Grid.FocusedCell.AxisContentItemY),0);
    aTimeItem.Start:=phGant1.DateScaler.Start+5;
    aTimeItem.Stop:=phGant1.DateScaler.Start+15;
    aTimeItem.Color:=Random(65000);
    aTimeItem.Style:=gtsPipe;

    aTimeItem.Row.CollisionDetection:=CBCollisionDetectOnRows.Checked;
    aTimeItem.Row.IncreaseRowHeightOnCollision_SuggestedHeightPerItem:=20;
    aTimeItem.Row.IncreaseRowHeightOnCollision:=CBIncreaseRowHeightOnCollisions.Checked;

  end;
end;

 

10032 : How can i Show arrows connecting two events in the gantt component? As in MS project, to show that a task begins when other is finished.

Question

How can i Show arrows connecting two events in the gantt component? As in MS project, to show that a task begins when other is finished.
Im evaluating your VCL component.

Answer

In code you do like this:

In VCL you use the method AddLink on the Gantt. This will give a a TphDataEntity_Link object that you should assign the LinkedTo and LinkOwner properties of this object, with time items (TphDataEntity_GantTime).