[Lazarus] The right way to handle variable heights of DBGrid rows

Andrey Smyntyna andreysmyntyna at gmail.com
Sat May 26 00:38:44 CEST 2012

Good evening!

Sample project, covered this message theme is attached to the mail.
Screenshot that illustrates problem is attached too.

I went into task of displaying multiline text in DBGrid cells and have
success, but some features of the DBGrid scrolling is out of my
If describe problem in short it lies in strange scrolling behaviour -
sometimes, selected row may be invisible for user, because it locates under
viewport or DBGrid can fill with records only half of visible area*. *
The code is very simple to understand:
1. TMyDBGrid is descendant of TCustomDBGrid, that overrides  PrepareCanvas
2. Within PrepareCanvas routine I set TextStyle with SingleLine=False and
WrodBreak=True fields and also calculate dimentions of rectangle that can
hold multiline cell text.
3. Height of text I strore in corresponding element of RowHeights array.

All text appears multiline and well formated, but if you look at screenshot
the two facts are obvious: selected row can be displayed under the bottom
of the visible part of grid and grid itself sometimes displayed half filled.

So, the problem now: what things should I change to have correct scrolling.

Best Regards, Andrey Smyntyna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variablescrolling.jpg
Type: image/jpeg
Size: 98541 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MultilineDBGrid_lazarus_list.zip
Type: application/zip
Size: 130800 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0002.zip>

More information about the Lazarus mailing list