[Lazarus] Fitting a form around a grid

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Jun 16 14:32:18 CEST 2011


 
 

 Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> hat am 16. Juni 2011 um
12:28 geschrieben:

 > It's obviously easy enough to fit a grid into the client space of a form
 > or panel, but how does one do the reverse?
 >
 > The exact size of a grid (i.e. such that the outermost grid lines are
 > either displayed or not displayed predictably) depends on the widget
 > set, and possibly on other details such as fount metrics, screen DPI and
 > so on. At present I find myself applying "fudge factors" when shrinking
 > a form to be an exact fit around a grid of a predetermined number of
 > rows and columns, and that's still not entirely reliable when moving
 > between systems.
 >
 > Is there a "correct" way of doing this? 
When you set the Forms.AutoSize to true, the form will automatically adjust its
size. See the wiki for details. For example you can set the Grid.Align to
alClient. Then the form will use the preferred size of the grid. The problem is,
that TStringGrid does not override the method CalculatePreferredSize, so the LCL
does not know the preferred size of the grid and therefore can not auto size the
form. 
You can define your own TStringGrid descendant that overrides the method. 
Or you can set the grids constraints. 
 
 Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110616/b7afeb6f/attachment-0003.html>


More information about the Lazarus mailing list