10505 : newactivity.GridRowIndex is -1

Question

I’m using the COM component and need help working with row heights and labels on a time object.  I’m using TimeItemsTextSetEx to display the text above the time item, but I’m having trouble determining how to resize the row height.  Here’s the code I’m using based on the GanttTest sample that installed with phGantt:

Private Sub LoadTreeItemsOwnedBy(activity As IphDataEntity_Tree2, ownerid As Integer) Dim newactivity As IphDataEntity_Tree2 Dim aRS As Recordset Dim selectstat As String Dim y As Long
   
    selectstat = “select id,name,owningactivity from activity where owningactivity=”
    selectstat = selectstat + Str(ownerid)
    Set aRS = New Recordset
    aRS.Open selectstat, db, adOpenStatic, adLockReadOnly
    While Not aRS.EOF
        If activity Is Nothing Then
            Set newactivity = phGantX1.AddRootDataEntityTree
        Else
            Set newactivity = phGantX1.AddDataEntityTree(activity)
        End If

        y = newactivity.GridRowIndex
        InitActivity newactivity, aRS
        LoadTreeItemsOwnedBy newactivity, newactivity.UserIntegerReference
        If y >= 0 Then
            phGantX1.SetRowHeightGrid y, phGantX1.GetRowHeightGrid(y)
        End If
        aRS.MoveNext
    Wend
End Sub

The problem is that y always evaluates to -1.  How do I resize the rows?  Thanks.

Answer

Not entirily sure why the y = newactivity.GridRowIndex is -1 in this case. Could be a couple of things… First; ary using the grid Gantt.UseGrid=true? If not the old tree is used and then no grid nodes will exist -> Set Gantt.UseGrid=true.
Second; It could be that you are in this load loop and that the Grid items get no chance to update them self. To verify if this is the case, loop thru the nodes in a button implementation and get GridRowIndex, if it is ok then its an update problem… Send us a sample, so we may debug and find out how to fix it.

Anyway, you can also control GridRowHeights by the defining a IphGridLayoutPropX, set its MinHeight property and assign it to at least one cell in the row (IphGantX3.SetGridCellLayoutPropIndex), and your row will get that row height (only works for UseGrid=true)

10512 : Can we drill down on any bar in the gantt chart?

Question

Can we drill down on any bar in the gantt chart?

Answer

If the question is “Can we catch all possible events on a time item” the answer is yes. The term “drill down” implies that there is data “under” this time item, and there probably is, but that is up to you to decide what that data is. Our components merly offer you a clean way to make changes and presentation to the data you provide.

10393 : Is it possible to freeze a time items X position already during the drag event?

Question

We already implemented that TimeItems can only be dragged and dropped vertically: That is, when you drag it in a diagonal direction, then , the moves horizontally to the original position. Is it possible to freeze the its position already during the drag event?

Answer

In the phGantTimePackage this is not possible. This is due to the fact that you may want to allow for a time item being shifted horizontally when it is on the same row. (To fix this we would need to extend product with a callback method so that you can decide x and y coordinates during move, if you want to sponsor this development you should contact sales to get a cost estimate)

10409 : Printing size

Question

I am wrestling with the parameters for printing the gantt chart.  I am trying to print on a 11 x 17 inch printer.  It prints in landscape mode correctly, but i want the image to take up the whole page.  Its stopping at about 7.5 inches horizontally.  Can u provide an example of how do to this?  Here is the code i am using:

LOCAL w as  long,h as long
w=0
h=0

thisform.gant1.printToDefault(1, 150, 5, 5,;
        thisform.gant1.treeWidth,;                          
        thisform.Gant1.TopItemTree, -1, .f., ;
        thisform.Gant1.Start , ;
        thisform.Gant1.Stop  ,; 
        thisform.gant1.getScaleLen,;
        thisform.gant1.scalerHeight, @w, @h)  

Answer

The Gantt works on pixels and you need to convert your inches from the printer to points or pixels. This is done by asking the printer for its resolution (this is standard windows but different in most environments).

Once you know how many pixels you want to fill you have two choices…
1. Use the available space in scale 1 to 1 that probably gives you very small time items on paper: To do this you would provide values for treewidth and ScaleLen that covers the available number of pixels.
or
2. Keeping the Treewidth and Scalelength more or less the same as on screen but calculate a scaling factor to use to fill the space: To do this you would go like this scale=PrinterPixelsInTheXDirection/(treeWidth+ScaleLen) and then use the scale in the PrintToDefault ( where you now use the value 5)

 

10359 : onDblClick Event in phSchema

Question

Hi,
how can I use the onDblClick Event in phSchema.
I would like to open a new window if i dblclick on an schematimeitem.

Answer

you can access the currently active SchemaTime (the latest clicked) with the ActiveDataEntity property:

  if Assigned(phSchema1.ActiveDataEntity) then
  begin
    phSchema1.RemoveSchemaTime(phSchema1.ActiveDataEntity);
  end;

Or you can use the info about clicked column and time:

var
  aphSchemaTime:TphDataEntity_SchemaTime;
begin
  if phSchema1.MouseDownColumn<>nil then
  begin
    aphSchemaTime:=phSchema1.AddSchemaTime(0);
    aphSchemaTime.Start:=phSchema1.MouseDownDateTime-1;
    aphSchemaTime.Stop:=phSchema1.MouseDownDateTime-1;
    aphSchemaTime.Col:=phSchema1.MouseDownColumn.ListIndex;
    aphSchemaTime.BackColor:=Random(65000);
  end;

 

10335 : Gantt component on my XP 64 bit system.

Question

I purchased the Gantt Time Package ActiveX a few years ago and it is working wonderfully. However, I switched to a new development PC which is running Win XP x64. I cannot get the plexityHide gantt installation program to run on this OS so that I can continue to develop my app in VB 6. All my other 32 bit components install and run fine on this machine.

Can you suggest a way that I can install the Gantt component on my XP 64 bit system. I feel certain that the component itself will work fine on this machine. I think it is just a restriction on the setup program.

Answer

If you still have a 32-bit system with the installation you can simply move the files from the installation folder.

The only important registration that takes place during installation is the regsvr32.exe call on the ocx, so you must do that by hand.( at the run prompt write regsvr32 <path>/phGantTimePackage.ocx).

 

10343 : Questions on Grid color and iterations

Question

I have 3 questions. I am using the phGant control in VB.

1. I want to color the background several rows in the grid, I ‘m using 4 columns in treegrid, how can I do this?

2. How can I edit the text in a time item?

3. How can I iterate through the timetems in the RootDataEntitiesTree and change the start from the timeitems, timeitems on the second level are unchanged

Thank you very much in advance.

Answer

To set seperate background colors in the grid you need to assign GridLayoutproperties to the cells. To declare GridLayoutProperties you go like this:

  phGantX1.GridLayoutPropAdd
  phGantX1.GridLayoutPropAdd
  phGantX1.GridLayoutPropAdd
 
  phGantX1.GridLayoutPropSet 0, ColorConstants.vbYellow, ColorConstants.vbBlack, “Helvetica”, 8, 20, 20, False, True, False, True, False
  phGantX1.GridLayoutPropSet 1, ColorConstants.vbRed, ColorConstants.vbBlack, “Helvetica”, 8, 20, 20, False, True, False, True, False
  phGantX1.GridLayoutPropSet 2, ColorConstants.vbBlue, ColorConstants.vbWhite, “Helvetica”, 8, 20, 20, False, True, False, True, False

And to use them on a specific cell you go can use the IphGantX3.SetGridCellLayoutPropIndex method.

2. There is currently no support to edit time item texts. If you need to you can bring up a dialog with an edit box. your would then use IphDataEntity_GantTime2.TimeItemsTextSet to update the text with the new value.

3. To iterate thru time items you go like this:

  // Another quicker way to get hold of all the time items

 

for(int i=0;i<axphGantX1.DataList3levGantTimes().Count();i++)

  {
    phGantXControl.IphDataList2lev aList2Lev=axphGantX1.DataList3levGantTimes().get_DataList2Lev(i);
   

for(int ii=0;ii<aList2Lev.Count();ii++)

    {
      phGantXControl.IphDataList aList=aList2Lev.get_DataList(ii);
     

for(int iii=0;iii<aList.Count();iii++)

      {
        phGantXControl.IphDataEntity_GantTime2 aGantTime=aList.get_Items(iii)

as phGantXControl.IphDataEntity_GantTime2;

        aGantTime.Start=aGantTime.Start.AddDays(1);
        aGantTime.Stop=aGantTime.Stop.AddDays(1);
      }
    }
  }

10571 : Time items with a color gradient?

Question

what should I do that the time items appear in 3d? I mean to get a color gradient?

Answer

In GTP.NET you can set the TimeItemLayout this way:

ti1.TimeItemLayout=new TimeItemLayout();
ti1.TimeItemLayout.BrushKind=BrushKind.GradientDiagonal;
ti1.TimeItemLayout.Color=Color.YellowGreen;
ti1.TimeItemLayout.GradientColor=Color.Yellow;

In phGantTimePackage you can get a gradient effect doing like this:
time.Style = txTimeStyle.tsPipe;

10237 : It is not possible to set the CanEdit-Property of ” IphDataEntity_SchemaTime” to False.

Question

It is not possible to set the CanEdit-Property of ” IphDataEntity_SchemaTime” to False. It is always True and therefore the Schematime can be moved every time?

Answer

If you implement this event IphSchemaX3.OnBeforeCanEditSchemaTime that is fired just before the edit starts on SchemaTime, you can set CanEdit=false on the SchemaTime in the argument, and stop editing.

10392 : Can you have horizontal lines across the Gantt chart? Our users do not want Pyjama alternative colours but have requested horizontal lines to distinguish rows.

Question

I posted a Question half a year ago:

Can you have horizontal lines across the Gantt chart? Our users do not want Pyjama alternative colours but have requested horizontal lines to distinguish rows.

The answer was: draw a line using GDI. We did this, but there are difficulties with printing. You have to make a (nonlinear) correction for vertical line distances for different rowheights, for the report to display the same as the monitor-gantt. Also big problems arise when you have different rowheights within one ganttchart.

The reason why many user prefer horizontal lines is clear: as a black/white print output it is clearer and saves ink.

Will you offer horizontal lines as a standardfeature in future, as an alternative to pyjamas?

Answer

Sure we could extend the API to allow for row separating lines, but if there are issues with positioning user drawn things when printing we would like to fix it. Chances are that there is some simple mistake in your current code. Can you send me a sample showing the problems you have with printing and positioning of your user drawn lines and I will take a look at it…