When the GanttRow.CollisionDetect and GanttRow.IncreaseRowHeightOnCollision properties are set to true, the TimeItems that are not in a collision-area are shown as filling the entire height of the now expanded row.
When trying to resize them using the suggested solution in Q10210, the drawing itself shows a regular sized TimeItem, but the text and all the events still apply to the old Region, which covers the entire height of the row.
How do I redefine the TimeItem’s Region so that I will have a regular-sized and regular-behaving TimeItem while still enjoing the benefits of showing the collisions on an increased row?
This is how to use the OnTimeItem_UserDrawBounds and OnTimeItem_UserDraw together:
In the OnTimeItem_UserDraw event change the given Rect and Bounding Region (make them as thin as you need)
Start with the rect and create a new region:
e.BoundingRegion = new Region(rect);
In the OnTimeItem_UserDrawBounds you must do the same(assign new e.Rect and e.BoundingRegion), since this event Is fired when the logic is finding out the size of the time item for other reasons than drawing.
private void buttonSetUpTestSizeOverride_Click(object sender, EventArgs e)
gantt1.OnTimeItem_UserDraw += new TimeItemEvent(gantt1_OnTimeItem_UserDraw);
gantt1.OnTimeItem_UserDrawBounds += new TimeItemEvent(gantt1_OnTimeItem_UserDrawBounds);
GridNode gn=new GridNode();
GanttRow gr = GanttRow.FromGridNode(gn);
ti.TimeItemLayout=ti.TimeItemLayout.Clone() as TimeItemLayout;
/// This event can help you override how a time item is perceived in the TimeItemFromXY (the active clickable area )
void gantt1_OnTimeItem_UserDrawBounds(Gantt aGantt, TimeItemEventArgs e)
GraphicsPath gp=new GraphicsPath();
/// …and this event helps you draw something in that area.
/// Note that the two areas can differ, its up to you, but it will a bit strange…
void gantt1_OnTimeItem_UserDraw(Gantt aGantt, TimeItemEventArgs e)
GraphicsPath gp = new GraphicsPath();