10722 : How can I stop ing a TimeItem when user drags the TimeItem into a Time item area which is designated as a holiday or non-working area.

Question

I am using GTP.NET

How can I stop droping a TimeItem when user drags the TimeItem into a Time item area which is designated as a holiday or non-working area.

I have used “OnTimeItemAreaScalerPaintBackground” event to paint holidays and non-working days in different colour. I do not want users to drag the time items into those areas.

Thank you.

Answer

You probably do not want to stop the drag over since it would irritate the user, but you can send visual feedback when the user is over a forbidden area. You can do this by changing the TimeItemLayout of the moving time item in the OnTimeItem_Hoover event: “Fired while mouse is moved and possibly over a time item. This is a good place to set e.Allow false if you do not want to allow the ongoing operation. You can also limit dragging in this event by e.x=gantt1.MouseDownPoint.X; will stop move in x direction ”

When the user actually drop the time item you can check that it is ok in the OnTimeItem_Move event. If it is not ok just set e.Allow=false and it will jump back.

 

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…

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

 

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/

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

 

10704 : How can I print only selected pages from a GTP.NET gantt?

Question

How can I print only selected pages from a GTP.NET gantt?

There does not seem to be a way of advancing to the first page of a selected page range.

Answer

We will always render all pages (to the printDocument) it is then up to the printDialog to send these pages to the printer.

You can instruct the print dialog to start on page x:

“The FromPage and ToPage properties are used by the PrintDialog when the user selects a print range. The PrintDialog.AllowSomePages property must be set to true to enable the user to specify a print range. In addition, the PrintDialog requires the MinimumPage and MaximumPage to be specified and the FromPage value to be within that range.”

So why are all pages processed if we only want to print page 5?

The number of pages is not known until the printDocument has finished. We need to see how many nodes that fits on each page.

The frameWork is really very flexible. Let me show you this:

   PreviewPrintController y=new System.Drawing.Printing.PreviewPrintController();
   y.UseAntiAlias=true;
   printDocument.PrintController=y;
   printDocument.Print();
   PreviewPageInfo[] aPreviewPageInfoList=y.GetPreviewPageInfo();
   aPreviewPageInfoList[5-1].Image  <— The image(EMF) of page 5…