Problems with the LayoutControl-script of a form datagrid

Fredrik Andersson fredrik at morbug.se
Tue May 12 03:32:11 EDT 2009


Hi everyone,

I've been lurking for a couple of months here (and for a couple of  
years on the forums) but I havn't had much to say. Anyway, it's been  
very interesting reading so far and I'm looking forward to learning  
even more in the future :)

Oh, and I have a small problem regarding datagrids that I hope someone  
can help me with:

I'm writing a small report viewer app that loads a textfile with  
tagged data and then displays it in various text fields and datagrids  
on several cards in my stack. So far I've only used datagrids with the  
table format but today I started converting one of these to a form  
format (which is more appropriate). I looked at the examples in the  
datagrid manual and managed to load the data into the array and then  
put it into the datagrid. The layout didn't work as expected though.

One of the fields ("Rang") is supposed to be at the far right of the  
control while the other fields (at the moment) is displayed left  
aligned along the left border of the control. I copied some code from  
the manual and wrote this code:

ON LayoutControl pControlRect
     local theFieldRect
     set the right of field "Rang" to item 3 of pControlRect -10
     put the left of field "Rang" of me into theLeft

   put the rect of field "Namn" of me into theRect
     put theLeft -10 into item 3 of theRect
     set the rect of field "Namn" of me to theRect

... and three more fields like the one above ....

     set the rect of graphic "Background" of me to pControlRect

END LayoutControl

When I load the data into the datagrid the line no 1 and 7 is  
displayed correctly (at the most there are 10-12 lines to display at  
the moment). The other lines has the "Rang"-field displaying in  
roughly the centre of the control, not at the right as it's supposed  
to. The other controls in those lines correctly aligns to this faulty  
position and isn't long enough to display all the text I want them to.  
Oh and the controls on the naughty lines doesn't scale as I change the  
size of the window.

Anyone got any idea why only one in seven lines display correctly?

Thanks in advance,

Fredrik Andersson



More information about the use-livecode mailing list