10733 : How do I implement the OnUnhandledException event?

Question

How do I implement the OnUnhandledException event. It does not seem to exist in your object model?

Answer

The event must be implement in code. The event catches exceptions raised in the draw loop. Since all parts of the gantt has possiblity to inject user code in draw loop, all parts has this event.

In c# write 

Gantt.Grid.OnUnhandledException+= and press tab
Gantt.TimeItemArea.OnUnhandledException+= and press tab
Gantt.DateScaler.OnUnhandledException+= and press tab

10794 : I have to know the total height (height that the grid would have to let all gridnodes visible) of the grid before beginning to print?

Question

I don’t use MS print component to print GTP.NET.

I have to know the total height (height that the grid would have to let all gridnodes visible) of the grid before beginning to print, i can’t just let looping while the gantt says it has more pages to print.

it seems that you calculate cell or ganttrow size only when you have to paint, so i can’t get “real” size of gridnodes that are not visible can you help me?

Answer

Correct, the sizes are only known when actually rendering.

So you need to render to something to get it to calculate all sizes. And that “something” must also be big…

One way is to use a metafile-canvas. Make it crazy big and print to it… Then all values are known… To print to a meta file look here: https://plexityhide.com/faqs_gen_GTPNET/10374.htm

 

10912 : I am using the ASP component and I would like to hide both the pan and zoom controls in the Gantt component.

Question

I am using the ASP component and I would like to hide both the pan and zoom controls in the Gantt component. Is this possible and if so how?

Answer

Yes we look at these properties Gantt_ASP.Gantt.DateScaler.ScrollButtonsVisible and Gantt_ASP.RescalingButtonsVisible

Just set them to false…

10898 : I want to click/doubleclick on an empty spot in the chart to create a new item in Gantt_ASP.

Question

I’m currently evaluating the GTP.WEB component to visualize a online booking application. I’ve had no problem binding data and viewing it in the Gantt chart, but now I want to click/doubleclick on an empty spot in the chart to create a new item. So my question is what is the easiest way of accomplishing this? Which events should/could be used and how do I pass along the information about where in the chart I clicked?

Answer

Download the latest release 3.0.5.10 and you will have a new event on the Gantt_ASP called:

Gantt_ASP1.OnGanttRow_ClientClick

You can implement that with code looking more or less like this:

  void Gantt_ASP1_OnGanttRow_ClientClick(Gantt_ASP aGantt, GanttRowClickEventArgs e)
  {
    if (aGantt.MouseButton_ClientSide == 1 && e.ThisClickSelectedLink==null)
    {
        DataRow dr=dataSet1.Tables[“timeitem”].NewRow();
        dr[“owner”]=(e.Row.GridNode.ListItemWhenDataBound() as DataRowView)[“id”];
        dr[“start”]=aGantt.Gantt.DateScaler.PixelToTime(e.X);
        dr[“stop”]=aGantt.Gantt.DateScaler.PixelToTime(e.X).AddDays(2);
        dataSet1.Tables[“timeitem”].Rows.Add(dr);
    }
    LabelClickInfo.Text=”You clicked GanttRow with id “+((e.Row.GridNode.ListItemWhenDataBound() as DataRowView)[“id”]).ToString();
  }

This is the code currently running in the sample found here: http://www.plexityhide.nu/

10888 : I would like to apply a vertical stripe to a specific day (or days)

Question

I would like to apply a ‘vertical stripe’ to a specific day (or days), I want to use this to show non working (or holidays) using the same technique you use for painting your vertical stripes. How can I achieve this please.

Answer

In order to do this you must know when a day starts and stops in pixels, this is easily found by sending in a datetime to the Gantt.DateScaler.TimeToPixel method.

So in pseudo code I would go like this:

In the implementation of the OnTimeItemAreaPaintBackground event

int numberOfDaysOnScreen=Round(Gantt.StopTime-Gantt.StartTime)
for i=0 to numberOfDaysOnScreen-1 do
begin
  DateTime oneDay=Gantt.StartTime+i
  Color c=GetColorForThisDay(oneDay)
  int PixelForStartOfDay=Gantt.DateScaler.TimeToPixel(Trunc(oneDay))
  int PixelForEndOfDay=Gantt.DateScaler.TimeToPixel(Trunc(oneDay)+1)
  DrawColoredRectangle(PixelForStartOfDay,0,PixelForEndOfDay,Gantt.Height)
end

 

10887 : I want to change the alignment of the vertical scroll to the left…

Question

I want to change the alignment of the vertical scroll to the left… currently it is in between the grid and time item area…

Answer

gantt1.Grid.ScrollbarNodes.Parent=gantt1.TimeItemArea;
gantt1.Grid.ScrollbarNodes.Dock=

DockStyle.Right;

Mind you it is not fully supported. The grid does not really know what is going on, so when it displays the horizontal column scroller it will leave some space for the vertical scroller although it is not part of the grid any longer. This can ofcourse be compensated for, but it is not shown in this sample.

To elaborate on this further you can put the scrollbar outside the gantt like this:

      Panel aPanel=new Panel();
      aPanel.Parent=gantt1.Parent;
      aPanel.Top = gantt1.Top + gantt1.DateScalerHeight;
      aPanel.Left=gantt1.Right+1;
      aPanel.Height=gantt1.TimeItemArea.Height;
      aPanel.Width=gantt1.Grid.ScrollbarNodes.Width;

      gantt1.Grid.ScrollbarNodes.Parent = aPanel;
      gantt1.Grid.ScrollbarNodes.Dock=DockStyle.Fill;

Since this is not an un-common request we will add support for this into the Gantt so that this function is built in and fully supported.

10699 : Strongly typed datasets in the samples

Question

That is not a question. Rather an idea.

In all your samples and tutorials using data binding you use DataRowView datastructure.
Personally I do not like it. The reason is simple. This structure is not strongly typed – you have to use casting every time when you want to get cell value. Moreover that code is string-based. You have to provide column name to get the value. Ugly 🙂

For my personal use I am using this function private GanttDataSet.TasksRow GetTasksRowForGridNode(GridNode node)
        {
            if (node != null)
            {
                return ((GanttDataSet.TasksRow)((node.ListItemWhenDataBound() as DataRowView).Row));
            }
            else
            {
                return (null);
            }
        }

It casts DataRow to particula data row related to my DataSet (GanttDataSet). After that i can use stronly typed properties representing grid columns. That is nice I think 🙂

Answer

We all agree with you that is always better to go for strongly typed implementations. But then again strongly typed datasets are not used by all developers, and the good old text based dataset where you access fields by strings is understood by everyone. And that is what we need; simple samples.

I myself use the ECO framework from Borland when doing anything a bit more complex than a sample; checkout this article for a brief : http://bdn.borland.com/article/0,1410,33092,00.html

 

10874 : I want to change the default resolution of the datescaler.

Question

I want to change the default resolution of the datescaler. By default it shows the datescaler resolution in days and i want to show it in quarters by default… how is this possible….????

Answer

DateScaler Class : TimeSpanSet Method will allow you to set the start and stop date of the view. Set values that are far enough apart to tell the datescaler that the quarters. Like:

Gantt.DateScaler.TimeSpanSet(DateTime.Now,DateTime.Now.AddDays(365));