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.