+1  A: 

It's difficult to say what you want to achieve, but seeing that you have a long text that spans multiple columns I'm not sure you use the proper event - usually you want text to be truncated if it's too long for its column.

Anyway, the best thing is to read section 5.2 "Paint cycles and stages" in the VirtualTreeView.pdf documentation file, and find the proper event to be used for what you want to paint. For OnAfterItemPaint it states:

The after item paint stage is used to add node specific stuff like frames and the like which concern all columns of that node and is called once per node.

so I guess it's probably not the one you want to use.

Edit:

OK, if you're going for the merging of cells you only need to remove the addition of VT1.OffsetX (and add VT1.TextMargin instead) to get the correct behaviour. This assumes of course you want to start the text output in the first (index 0) column, otherwise you have to calculate the horizontal text position from the column widths.

But from the description of the paint stages I still would rather use the BeforeItemPaint event and set the CustomDraw var parameter to True to skip any default painting.

mghie
Atlas
Thanks, the issue has been fixed, I should have used TextMargin instead of OffsetX.
Atlas
A: 

Have you tried this:

TreeOptions.AutoOptions := TreeOptions.AutoOptions + [toAutoSpanColumns];

It pretty much does what you need. They only issue might be that you can't specify which columns it is enabled for. You can probably get around this by limitation by setting the celltext to a whitespace for the columns you don't want to span into.

norgepaul