10373 : Is it possible to control the drawing of TimeItems so that if the TimeItemText is not contained within the area of the TimeItem box then I can use the TimeItemTexts box as the box of the TimeItem.

Question

I am developing a Gantt tool which will have to display a LOT of data. Is it possible to control the drawing of TimeItems so that if the TimeItemText is not contained within the area of the TimeItem box then I can use the TimeItemText’s box as the box of the TimeItem. This would ensure that the text did not overlap a subsequent TimeItem

Also, how do I get hold of the box data?

Also is it possible to expand a time-item’s height according to the number of lines the TimeItemText has wrapped to. How can I find out this number?

Answer

None of the things you ask for are available out of the box, but you can solve them all using the user draw technique. Take a look at this article that discusses OnTimeItem_UserDraw: http://plexityhide.dyndns.org/InstantKB13/Article.aspx?id=10210

In the OnTimeItem_UserDraw event you get the bounds of the box: e.Rect. The same value is also available in the TimeItem.DrawRect property. To get the bounds of the TimeItemText you need to meassure the text with the Graphic.MeasureString method from GDI. The Graphics object is also supplied in the TimeItem_UserDraw event.

These are good ideas and we will consider to extend the TimeItemLayout to handle these things in the future. Thanks!

Leave a Reply