10860 : How can i set another color for the arrow while linking 2 activities?

Question

How can i set another color for the arrow while linking 2 activities (default is black) and also another width ?

Answer

Set these properties:

gantt1.TimeItemLinks.CreationTimeItemLinkWidth and
gantt1.TimeItemLinks.CreationTimeItemLinkColor

 

10638 : Is it possible to restrict the movement of a timeitem to specific rows?

Question

Is it possible to restrict the movement of a timeitem to specific rows? E.g. If I have a timeitem placed in row 1 and I have a total of 6 rows, but I will only allow the timeitem to be repositioned at row 2 and 3.

Answer

Sure! What you do is to implement the OnTimeItem_ChangeRow event and check if the e.NewGanttRow is one of your illegal rows. If so set e.Allow=false. Done.

10808 : Creating a time item legend

Question

I want to create a form containing a legend for the time items i use in my chart. I create all my items (and there layouts) in a factory. So, if i change the layout in the factory to do changes to my chart, i want the changes to be automatically taken over in the legend (since the timeitems in the legend are also creteated by the same factory). Is something like that imaginable?

Answer

Yes. You can use the static class TimeItemDraw for this. It exposes the draw implementation of time items. You can send in your own Graphics object from the panel.

10667 : Is it possible to have different font color for Header and the cell?

Question

Hi, Is it possible to have different font color for Header and the cell. If I set property in the celllayout it applies to whole of grid. I want to apply different font colors to the headers and the cell.

Answer

Yes. You can assign a unique CellLayout to each cell. The Column heads can also be treated as cells: GridColumn.ColumnCell so you can assign CellLayouts to them to.

You can find a CellLayout from a CellLayoutName like this Grid.CellLayouts.GetFromName(“theNameOfTheCellLayout”);

This sample shows how a header cell in Gantt_ASP is given a Bold type face:

CellLayout cl=new CellLayout();
cl.Name=
“ABoldCellLayout”;
cl.Font=
new Font(FontFamily.GenericSerif,14,FontStyle.Bold);

Gantt_ASP_Vendor.Gantt.Grid.CellLayouts.Add(cl);

// When using Gantt_ASP it is even more important to add the cellLayout to this collection, or else it will not we added to the css

Gantt_ASP_Vendor.Gantt.Grid.Columns[0].ColumnCell.Layout=Gantt_ASP_Vendor.Gantt.Grid.CellLayouts.GetFromName(

“ABoldCellLayout”);

10603 : Finding selected time items

Question

I have a gantt with an OnTimeItem_SelectionChanged Event.

In this event, I need to find out, how many TimeItems are selected.
In addition, I need to iterate through the selected TimeItems and/or the attached GanttRow’s.
Is there an appropriate collection in your object model?

Answer

gantt1.GetSelectedTimeItems returns TimeItem[]

For each time item you get the GanttRow from timeItem[x].Layer.GanttRow

10659 : How to rotate something in the background draw…

Question

In my application I would like to draw some background text (using OnTimeItemAreaPaintBackground) to have some vertical text along a vertical line (where I can name a holiday, name a deadline, or whatever).

I tried doing this using a combination of G.TranslateTransform, G.RotateTransform, and G.DrawString in this event. I can successfully draw the string, but it seems to be messing up the Gantt’s own drawing when I do this.

Do you have any sample code on how to successfully draw background text like this?

Answer

When you rotate a Graphics object it will stay rotated until you rotate it back. In the sample below we draw some text at an 22 degree angle.

We then rotate the Graphics object back -22 degrees…

        Font font=new Font(FontFamily.GenericMonospace,46,FontStyle.Bold);
        Matrix matrix=new Matrix();
        matrix.RotateAt(22,new Point(0,0));
        G.Transform=matrix;
        G.DrawString(“Hey I am 22”,font,new SolidBrush(Color.FromArgb(alpha,255,0,0)),60,-40);
        Matrix matrix2=new Matrix();
        matrix2.RotateAt(-22,new Point(0,0));
        G.Transform=matrix2;
        font.Dispose

10605 : AfterMove when no move

Question

At runtime, when I click on a timeitem, sometimes the event gSchedule_OnTimeItem_AfterMove will raise. It causes a bug to happen.

How to prevent this?

Answer

A click on a time item can be percieved as a very quick and very small move of the time item.
The best way to tell the Gantt that these “none moves” should be ignored is to assing some value to the Snapping parameters of the TimeItemLayout for that TimeItem. Snapping will round the values so that the moving is controlled by a snapping grid.

See SnapStartTime and SnapStopTime in the help file.

10601 : Non working days

Question

It is any way to define a day as a “not working day” (for example: Saturday and Sunday)?

For example, it is necessary if a task’s duration is 2 days and it starts on Friday, it should finish on Monday and not on Saturday, because we defined Saturday and Sunday as not working day.

Answer

Each time item has a Start and Stop property, there is currently no functionality to have a derived stop time.

We are looking into this and our work aims to:

#1 On the TimeItemLayout choose if the Stop time is settable or if it is derived.
#2 If the Stop time is derived there should be an event that allows for its calculation

Currently you will need to do this yourself, outside the component.

10539 : OffscreenDraw.Graphics explanation

Question

When using the Gantt_OnTimeItemAreaPaintBackground event to draw things on the gantt chart what is the difference between using the aOffscreenDraw.Graphics object and e.G object. Both seem to work OK on the gantt chart but only the e.G works with the print preview. If I use the aOffscreenDraw.Graphics then the print preview does not show any of the items that I have drawn. Why?

Answer

You should use the Graphics object sent in to the event (e.G). The OffscreenDraw.Graphics is used to render the offscreen image produced by the Gantt. When you print you never render the result to the screen, and we send the rendered image to Graphics object you provide in the Print call.

So things you draw to OffscreenDraw.Graphics directly is never really part of the Gantt, but rather put on top of the Gantt (and we only send the Gantt to the printer).

 

10519 : How can I limit scaling in Gantt_ASP?

Question

How can I limit scaling in Gantt_ASP?

Answer

To limit scaling etc in Gantt_ASP you can change the values of the datescaler in the postbacks… Like this sample that limits the shown span to 100 days

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

    {

 

 

      if (!this.IsPostBack) // If this is not a postback then we init the datetime to Today + 15 days

      {

        Gantt_ASP1.StartTime = DateTime.Today;

        Gantt_ASP1.StopTime = DateTime.Today.AddDays(15);

      }

      else

      {

        // Limit the zooming to max 100 days

        if (Gantt_ASP1.StopTime.Subtract(Gantt_ASP1.StartTime) > new TimeSpan(100, 0, 0, 0, 0))

        {

          Gantt_ASP1.StopTime = Gantt_ASP1.StartTime.AddDays(100);

       

        }

 

      }