10090 : How can I change the size of the grid-area when I print my Ganttchart?

Question

How can I change the size of the grid-area when I print my Ganttchart?

Answer

When you print you call Gantt.PrintPage and this method has a a rectangle for the margins and a GridWidth, these parameters define the grid size.

System.Void PrintPage ( System.Drawing.Graphics G, System.Drawing.Rectangle Margins, System.Int32 aGridWidth, System.Int32 aDateScalerHeight, System.Boolean& HasMorePages) 

10091 : GTP ASP.NET: How can I change the font color for the column header in the grid?

Question

GTP ASP.NET: How can I change the font color for the column header in the grid?

Answer

You control this by defining the CellLayouts; same as for the the Gantt in windows forms.Set the CellLayout.HeaderBackgroundColor.

Note that in windows forms you can set Gradientcolors etc, but that is currently not supported in the asp version.

Create a named CellLayout:
      CellLayout layout=new CellLayout();
      layout.MinHeight=20;
      layout.Font=new Font(“Microsoft Sans Serif”,10);
      layout.FontColor=Color.Black;
      layout.VertAlign=StringAlignment.Center;
      layout.Name=“layout”;
      layout.HeaderBackgroundColor=SystemColors.Control;
      layout.LineRight.Use=true;
      layout.LineRight.Color=SystemColors.ControlDark;
      layout.LineTop.Use=false;
      layout.LineBottom.Use=false;
      gantt1.Grid.CellLayouts.Add(layout);

And reference it from a column:
      GridColumn idcol=gantt1.Grid.Columns.AddNew(CellType.SingleText);   
      idcol.Title=“Id”;
      idcol.LayoutName=“layoutrightjust”;
      idcol.Width=20;

 

10086 : When I move a GridNode using the method MoveNode my application hangs.

Question

When I move a GridNode using the method MoveNode lets say from node A to node B on position 0 and then back from node B to node A on position 0, my application hangs. The same works fine if the node is moved on the last position (pos = newParent.SubNodes.Count).
GTP.NET ver. 1.3.1

Answer

This was a bug that is patched. Download latest patch here

https://plexityhide.com/pub/PlexityHide.GTP.zip

10089 : Is there a way to turn off the relationship between the length of a timeitem and its timeitemtext?

Question

Is there a way to turn off the relationship between the length of a timeitem and its timeitemtext?
Because now when I have a short timeitembar, my timeitemtext is too short to display the whole text

Answer

Well not really, you can fallback on UserDraw and draw the time item and text yourself.

If you are using GTP.NET you can use the TimeItemTextLayout.OutsideText property, this will  draw your text outside the time item.

 

10072 : Can you turn off the ” Hand” mouse cursor when you hover the mouse over a timeitem in GTP.NET?

Question

Can you turn off the ” Hand” mouse cursor when you hover the mouse over a timeitem in GTP.NET?

I have some time items on the gantt representing “non available time”, so have properties AllowMove= false etc.  However, I would like them to also be ignored by the mouse over event.

Answer

Yes, you can implement the Gantt.TimeItemArea.OnPreCursorChangeEvent and change the cursor depending on the situation.

 

10069 : Can you have horizontal lines across the Gantt chart?

Question

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.

Answer

There is no “out of the box” setting to fix this but I suggest that you implement the OnTimeItemAreaPaintBackground event and simply iterate thru the rows and draw a line using GDI. You can have a look at the sample called Gantt_BackGround_ForeGround how to handle the drawing.

10070 : Can you change the format of the date on the date scaler?

Question

Can you change the format of the date on the date scaler?
We would like to change for example, “0502-08” to “May 02-08”, when at one week resolution.

Answer

Sure;
In GTP.NET you can set DateScaler.CultureInfoDateTimeFormat to change the date format to another cultural style to get the same effect in phGantTimePackage you must change the locales setting…

BUT you probably want to override the suggested output;
In GTP.NET Implement the event DateScaler.OnDateScalerDrawString and override the output by changing the argument e.OutputText.

Like this:
    private void dateScaler1_OnDateScalerDrawString(PlexityHide.GTP.DateScaler dateScaler, PlexityHide.GTP.DateScalerDrawStringEventArgs e)
    {
      
      if (checkBoxMyOwnWeekPres.Checked)
      {
        // If you want to customize the way the date scaler draws its strings, you can…
          if ((e.LongIntervall && e.Resolution==NonLinearTime.TimeResolution.days) && (!dateScaler1.UseDayNumbersNotWeeks))
          {
            // In this case we override the long intervall presentation when the resolution of the lower is Days ;
            e.OutputText=e.DateTime.ToString(“MMdd”)+” – “+e.DateTime.AddDays(6).ToString(“MMdd”);
            e.ContinueDraw=true;
          }        
      }
    }

Additional information from our friend Uli: I would like to change the DateScaler string. FAQ Q10070 describes a solution but there is a problem with the displayed DateTime which doesn´t agree to the displayed days. There is a small offset of three days. I did the following:

this.gantt1.DateScaler.OnDateScalerDrawString+=new DateScalerDrawStringEventHandler(DateScaler_OnDateScalerDrawString);
      this.gantt1.DateScaler.TimeSpanSet(DateTime.Today, DateTime.Today.AddDays(20));
      this.gantt1.DateScaler.UseDayNumbersNotWeeks=false;
      this.gantt1.DateScaler.ShowWeekNumbers=false;

void DateScaler_OnDateScalerDrawString(DateScaler dateScaler, DateScalerDrawStringEventArgs e)
    {
        if((e.LongIntervall&&e.Resolution==NonLinearTime.TimeResolution.days)&&(!this.gantt1.DateScaler.UseDayNumbersNotWeeks))
        {
            e.OutputText=e.DateTime.ToString(“dd.MM”)+” – “+e.DateTime.AddDays(6).ToString(“dd.MM”);
            e.ContinueDraw=true;
        }
    }

Supports answer: The answer to this is that weeks presentation is performed when drawMarker.DayOfWeek == timeLine.MidWeek, so Uli is correct. For week presentation the supplied date will need an AddDays(-3) for displaying the start of the week correctly. This was a bit unexpected in the design phase but we are keeping this behaviour so you can safely substract 3 days to get the start and add 3 days to get the end of the week (all cultures have 7 days a week right?!).

 

In phGantTimePackage you implement the event OnScalerStringShort and OnScalerStringLong to change the short and long intervall representation.

Also; the Gantt.DateScaler.ShowWeekNumbers=true and the Gantt.DateScaler.StartOfWeek property is an easy way to an alternative week presentation.

 

 

10068 : Complete iteration GTP.NET Gantt

This article describes a complete iteration of all important data carriers of the Gantt in GTP.NET:

 

   private void buttonCompleteIteration_Click(object sender, System.EventArgs e)< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    {

      // The root-level of the grid nodes you access this way;

      for(int i=0;i<gantt1.Grid.RootNodes.Count;i++)

      {

        DoCompleteIterationForOneNode(gantt1.Grid.RootNodes[i]);

      }     

    }

   

    private void DoCompleteIterationForOneNode(GridNode gn)

    {

      // Each gridnode has one cell per column

      for(int i=0;i<gn.GridStructure.Columns.Count;i++)

      {

       Object o=gn.GetCell(i).Content.Value;

      }

     

      // Each gridnode that is part of a gantt-grid has a GanttRow

      GanttRow gr=GanttRow.FromGridNode(gn);

     

      // Each GanttRow has layers, the normal scenario is that the GanttRow only has one layer

      for(int i=0;i<gr.Layers.Count;i++)

      {

        // Each Layer has time items

        for(int ii=0;ii<gr.Layers[i].Count;ii++)

        {

          // Each Layer has time items

          TimeItem ti=gr.Layers[i][ii];

          

          //a Time item can have time item texts

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

          {

            ti.TimeItemTexts[iii].Text=””;

          }

         

          // and a time item can also have links….         

          ArrayList links=gantt1.TimeItemLinks.GetLinksFromStart(ti);

         

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

          {

            TimeItemLink til=links[iii] as TimeItemLink;

            // Once you have a link you can access the seperate time items

            TimeItem ti1=til.Target;

            TimeItem ti2=til.Start;

          }

         

        }

       

      }

     

      // A grid node may have sub-nodes….

      for(int i=0;i<gn.SubNodes.Count;i++)

      {

        DoCompleteIterationForOneNode(gn.SubNodes[i]);

      }

     

    }

 

10067 : The function AddLink(ti1, ti2) requires a reference to another timeitem, but I dont know how to fetch that one (something like getTimeItemFromID…)?

Question

Is it possible add timeitemlinks after I have drawn the timeitems?
The function AddLink(ti1, ti2) requires a reference to another timeitem, but I dont know how to fetch that one (something like getTimeItemFromID…)?

Answer

Depending on how you load the gantt you can do this different ways. But anyway you go you will need to find the two time items that should be linked. You can find time items by iterating the chart, or you can put a reference to all added time items in a Hash list sorted on some key you use. You can use the UserReference item to put a key.