Question
At present draggging the header of the control zooms in and out. Instead I would like to be able to move backwards and forwards through the days when dragging.
Answer
Set the gantt.DateScaler.ReScaleWithControl=true
Question
At present draggging the header of the control zooms in and out. Instead I would like to be able to move backwards and forwards through the days when dragging.
Answer
Set the gantt.DateScaler.ReScaleWithControl=true
Question
Is it possible to extend the properties of a timeitem by adding custom properties? Without the need of the source code? I’m thinking that maybe it could be done by using the userreference in some way?
Answer
Yes, that is what the UserReference is for. Put an object here and that object can have any properties you can think of. We will never touch UserReference so anything you put here is your own thing completly.
Question
I would like to use your Gantt control in one of our projects, but our clock doesnt have units. We have a discrete simulation product. One of our object types is called a scenario event. It has a start and stop time so it makes sense to have them edit via a gantt chart. Is there a way to change the date scaler to show numbers from 0 to infinity with zooming functionality like you have except broken up by powers of 10?
Answer
You can implement the OnDateScalerPaintForeground event and use the time base from Start to Stop to create your own scale presentation. This is the standing recomendation for clients that need something we never thought of in the first place, and it should give you complete freedom of that design; on the other hand it gives you complete freedom to do the work as well 🙂
Question
Hi, I would like to draw tick marks inside of a time item. I am using the “OnTimeItem_UserDraw” event and that works fine. An example might be that I would like to have a time item that is 10 minutes long and draw a tick every minute. So when I zoom in and out I the ticks would move around. Is there a way to do this? Perhaps there is a way to get the start and stop time of the region being drawn?
Answer
To draw accurate time based pixels in a user drawn time item you will need to use the DateScaler.PixelToTime and DateScaler.TimeToPixel function.
You can loop from your TimeItems.Start value to TimeItem.Stop. For every second you call DateScaler.TimeToPixel and draw a scale mark.
Question
How can I change the sequence to overlap the timeitem? Now the timeitem that begins before is in top to the strip of the overlapped timeitem. Can I choose the order with that superimpose the item in case of collision ?
Answer
The CollisionDetection places early time items in the highest position. The way it does this is by assigning a non zero value to the SubCol property of the TimeItem object.
If the Owning GanttRow has SubColumns<>0 then the row is divided into sub rows (they are called sub columns for historic reasons and its a good name when the gantt is in the ScheduleMode) time items with a non zero value less or equal to GanttRow.EffectiveSubColumns will be draw in the sub row corresponding to that number.
So if you want to have the time items the other way around (early time items in a lower position) you can change the SubCol property after or in the OnCollisionDetect event.
Question
Hi, is it possible to limit the height of the FishEye area in the DateScaler (for example to the two lower rows)? It looks not very nice when the DateInformation row is also colored with the FishEye color.
Answer
Currently there is no exposed property to control the height, but you can give the FishEyeColor the same color as the rest of the datescaler and then draw the background yourself in the DateScaler.OnOffscreenPaintBackground event.
Question
Hi,Is it possible to get the PlusMinus sign to be in the middle of the cell (Horizontal = Left, Vertical = Center) instead of the top left corner?
The column is a custom cell, but Im not painting the symbol.
Answer
From version 2.3.1.15 the CellLayout.VertAlign is taken into account when drawing the plus.
Question
I am using GTP.Net and I would like to ask is it possible to drag a time item to a control for example ListView? I want the time item to be able to move around (change start time) when the cursor is within the gantt chart. But if the time item is drag to the listview (or the mouse is drag to the listview), I need to pick up the time item text (which is being drag) and display it to the ListView and delete it (the time item being drag). Is it possible? Thanks a lot.
Answer
You want to switch from internal drag drop to “Normal” windows forms drag drop. No sweat.
In the code below we choose to cancel the started internal mouse move operation and instead start the Control drag drop.
We then treat another Gantt as a reciver, but this is where you should handle you listbox...
private void gantt1_OnTimeItemAreaMouseDown_1(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.richTextBox1.Text = "gantt1_OnTimeItemAreaMouseDown\n" + this.richTextBox1.Text;
if (gantt1.TimeItemFromPoint(e.X,e.Y)!=null)
{
TimeItem thedraggedTimedItem=gantt1.TimeItemFromPoint(e.X,e.Y);
gantt1.TimeItemArea.DoDragDrop(thedraggedTimedItem,DragDropEffects.All);
gantt1.MouseMoveCancel();
}
}
private void TimeItemArea_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(PlexityHide.GTP.TimeItem)))
{
e.Effect=DragDropEffects.All;
}
}
private void TimeItemArea_DragDrop(object sender, DragEventArgs e)
{
this.richTextBox1.Text = "DROP\n" ;
GanttRow gr=gantt2.GanttRowFromY(gantt2.TimeItemArea.PointToClient(new Point(0,e.Y)).Y);
//GanttRow gr=null;
//Cell c=gantt2.Grid.GridStructure.CellFromXY(0,e.Y);
//if (c!=null)
// gr=GanttRow.FromGridNode(c.Node);
if (e.Data.GetDataPresent(typeof(PlexityHide.GTP.TimeItem)) && gr!=null)
{
TimeItem theOneToMove=e.Data.GetData(typeof(PlexityHide.GTP.TimeItem)) as TimeItem;
TimeItem nti=gr.Layers[0].AddNewTimeItem();
nti.Start=theOneToMove.Start;
nti.Stop=theOneToMove.Stop;
}
}
}
Question
In gantt.net it is possible to move a timeitem by code(programmatically) from a ganttrow to the other one?
Answer
Yes. You do it by removing the time item from the old layer and add it to the new one:
timeitem.Layer.Remove(timeitem);
newGanttRow.Layers[theLayerIndex].Add(timeitem);
Question
Please give me the example of how to use the OnPreCursorChangeEvent to change the cursor…..
Actually i want to change the cursor while resizing the stop value of time item. bydefault it shows sizeWE cursor while resizing the stop value of the time item. i want to show my own cursor while resizing the stop value of timeitem
Answer
To do this you implement the event Gantt.TimeItemArea.OnPreCursorChangeEvent (Do this in code).
You can change the cursor based on the Gantt.MouseMoveKind value
gantt1.TimeItemArea.OnPreCursorChangeEvent += new PreCursorChangeEvent(TimeItemArea_OnPreCursorChangeEvent);
void TimeItemArea_OnPreCursorChangeEvent(OffscreenDraw aOffscreenDraw, PreCursorChangeEventArgs e)
{
if (gantt1.MouseMoveKind==MouseMoveKind.resizee)
{
e.Cursor=Cursors.Cross;
}
}