Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-05

The right way to handle variable heights of DBGrid rows

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrey Smyntyna

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 understanding.
If describe problem in short it lies in strange scrolling behaviour - sometimes, selected row may be invisible for user, because it locates under DBGrid
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 procedure
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.freepascal.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0001.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.freepascal.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0001.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.freepascal.org/pipermail/lazarus/attachments/20120526/094402f6/attachment-0001.zip>

Reply by email

Andrey Smyntyna

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 understanding.
If describe problem in short it lies in strange scrolling behaviour - sometimes, selected row may be invisible for user, because it locates under DBGrid
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 procedure
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.freepascal.org/pipermail/lazarus/attachments/20120527/01df408b/attachment-0001.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: variablescrolling.jpg
Type: image/jpeg
Size: 25907 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120527/01df408b/attachment-0001.jpg> -------------- next part --------------
A non-text attachment was scrubbed...
Name: MultilineDBGrid_lazarus_list.zip
Type: application/zip
Size: 4846 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120527/01df408b/attachment-0001.zip>

Reply by email