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;

 

10049 : Hiding a time item

Question

I m using phGantTimePackage and I would like to know how to hide a time item. I tried to set Visible property to false, but the gant item does not dissapear.

Answer

The Visible feature is regretfully not implemented for time item. You will need to remove the time item, and later create it, or move it it time. One suggestion is to add ten years to the start date