Datagrid form putting fields under variable height field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
cusingerBUSCw5N
Posts: 335
Joined: Wed Jul 11, 2012 9:24 pm

Datagrid form putting fields under variable height field

Post by cusingerBUSCw5N » Fri May 10, 2013 1:36 am

I've just figured this out, so I am posting this to save others from wasted time. I have a datagrid form and the top field varies in height. I wanted to put a button underneath the form. So here's how I did it.

In Row Behavior, under Layout Control, first you set wher eyou want the top fields. In my case, it looks like this:

put item 1 of pControlRect into ttry
put the left of graphic "ArrowExpanded" of me - 6 into item 1 of theFieldRect
put the width of graphic "background" of me into twide
set the width of field "label" of me to twide*.80
set the left of field "label" of me to ttry + 55
set the top of field "label" of me to the top of graphic "arrowexpanded" of me

Now...I want field "label" to be able to expand... So, I created a new Rect... theFieldRect2. The following code lets that field switch heights.

put the rect of field "label" of me into theFieldRect2
put twide*.90 into item 3 of theFieldRect2
set the rect of field "label" of me to theFieldRect2
put item 2 of theFieldRect2 + the formattedheight of field "label" of me - the bottommargin of field "label" of me into item 4 of theFieldRect2
set the rect of field "labeL" of me to theFieldRect2

Then, I continue with setting all the other fields below it:

put the width of this stack into tstackwidth
put tstackwidth*.02 into thorizontalspace
put the height of this stack into tstackheight
put tstackheight*.02 into tverticalspace
set the top of button "email" of me to the bottom of field "Label" of me + tverticalspace
set the left of button "email" of me to the left of field "label" of me
set the top of field "testingnow" of me to the top of button "email" of me
set the left of field "testingnow" of me to the right of button "email" of me
and so on...

Then, at the bottom, I have it set the rect for the whole line, like this: (notice, I've gone back to original theFieldRect). So now, if the email button is showing (i.e. the form is expanded), then it shows all the way down to my bottom button...otherwise, it shows just to the bottom of my formatted "label" field with variable heights. Here is the code for the bottom:

put the left of graphic "ArrowExpanded" of me - 6 into item 1 of theFieldRect
put the top of field "label" of me into item 2 of theFieldRect
put the right of button "change" of me + 10 into item 3 of theFieldRect
if the visible of button "email" of me is true then
put the bottom of button "change" of me + 5 into item 4 of theFieldRect
else
put item 2 of theFieldRect + the formattedheight of field "label" of me +10 into item 4 of theFieldRect

end if
set the rect of graphic "Background" of me theFieldRect

Voila...It actually works!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”