I'm getting issues drawing using OnAfterItemPaint event when horizontal scrolling is performed.
Basically what I want to achieve is the merging of selected cells effect, say for example 1 text for column 1 & 2, another text for column 3 & 4, etc... So far VT doesn't have any support for column merging, so I have to manually draw it.
Is there a workaround or another event that I should use instead?
Using: Delphi 7 + VirtualTreeview 4.8.5
Event source:
begin
TargetCanvas.TextOut(ItemRect.Left+ VT1.OffsetX, ItemRect.Top,
'1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF');
end;
Before scroll:
alt text http://a.imagehost.org/0869/screen1.gif
After scroll (Scroll Right, then Scroll Left):
Have you tried this:
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.
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: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 addVT1.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 theCustomDraw
var parameter toTrue
to skip any default painting.