10291 : Elaborate on the time item text TimeItemTextLayout.OutsideText=true.

Question

There is a trick I would like to do, but I’m not sure what event would be best to do this in.

I have a gantt chart where there would be only one time item per row. The time item text shows up on the left-hand size of the time item (TimeItemTextLayout.OutsideText=true). When the user scrolls along the x axis (time) there would be some time items that would only be partially visible. In these cases you just see part of a time item and no text since the text is on the left of the time item.

In these cases, I would like to check for instances where the pixel width of the left-side text is partially obscured and then (for those time items that meet that criteria) do this:

TimeItemTextLayout.HorzAlign=StringAlignment.Far;

Its not a critical thing, but spit & polish make good applications great! 🙂

Answer

The TimeItemTexts are an easy way to display additional information in or around a time item. But if you need more advanced drawing that is dependent on additional parameters you should not be afraid of using the user drawn time items (TimeItemLayout.TimeItemStyle=TimeItemStyle.User;).

In this case you can implement the user draw for a time item, draw the default look of the time item with the TimeItemDraw class and draw the text exactly were you want it with standard GDI operations.

Leave a Reply