datagrid problem resolved
Trevor DeVore
lists at mangomultimedia.com
Mon Aug 17 09:46:39 EDT 2009
On Aug 16, 2009, at 5:09 AM, Yves COPPE wrote:
> if you have a fld in a datagrid ( Form style) and this fld (let us
> name him : "body") contains from row to row a variable text,
> you will use a layout script in the following form :
> put item 2 of theRect + the formattedHeight of field "Body" of me
> into item 4 of theRect
>
> It gives problems. if you want to avoid problems, you have to put a
> height to your fld "body" which is high enough so that the
> "formattedheight" can return a good value
>
> put item 2 of theRect + 50 into item 4 of theRect -- "50" is
> arbitrary
> -- then set the rect
> set the rect of fld "Body" of me to theRect
> -- now get the correct value of the Formattedheight
> put item 2 of theRect + the formattedHeight of field "Body" of me
> into item 4 of theRect
> set the rect of fld "Body" of me to theRect
To sum up, Yves had a field in his data grid template whose height was
adjusted to fit the text contents. His original code was setting the
rect of the field in one pass. The problem with setting the rect in
one pass when the field is being resized to fit the text height is
that the width of the field before setting the rect might not be the
width of the field after setting the rect. This means the
formattedHeight value might not be incorrect.
The proper way to have a field that adjusts height according to
content is:
on LayoutControl pControlRect
## ...
## First adjust width
put the rect of field "MyAdjustableHeightField" of me into theRect
put item 3 of pControlRect into item 3 of theRect ## adjust field
to new width
set the rect of field "MyAdjustableHeightField" of me to theRect
## Now adjust height
put item 2 of theRect + the formattedHeight of field
"MyAdjustableHeightField" of me \
into item 4 of theRect
set the rect of field "MyAdjustableHeightField" of me to theRect
## ...
end LayoutControl
--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Developer Resources: http://revolution.bluemangolearning.com
More information about the use-livecode
mailing list