Page 1 of 1

Hieght of data grid, without scrollbars

Posted: Sat Jul 09, 2011 9:45 am
by doobox
Hi there,

I am trying to get a data grid, for all intents and purposes, to re-size in height in the same fashion a text field does when fit content is selected.

I have a data grid inside a mobGUI scroller group. Set to form type. no scrollbars.
So at the moment i am testing with static content, a string on each row, some 20 rows.
So ok, i can set the height to suit at the moment.
But in the app the content will be generated by the user. So how can i get the data grid to re-size it's height dependent on the size of the content.

I can think of a way to script this. Count the number of rows present and multiply by my row height, then set the height to the answer.
Is this the only way to set the height of the grid when new content is generated...?

Re: Hieght of data grid, without scrollbars

Posted: Sun Jul 10, 2011 4:27 am
by dunbarx
I don't think that datagrids, as fields themselves do not, have any native property that expands (or contracts) them to fit content. The answer dialog, for example, does this but it and its ilk are a special case.

I don't use datagrids much, but what you propose sounds like a straightforward and logical method, what most would do with simple fields.There are many messages you can trap to update the dg's height, either before the user accesses or after he modifies the data.

Craig Newman

Re: Hieght of data grid, without scrollbars

Posted: Sun Jul 10, 2011 10:59 am
by doobox
Hi Craig,

Thank you...
If i understand you correctly, your saying even with a text field, there is not a way to mimic the behaviour of clicking "fit content" in the property inspector, at runtime.


I will run with my initial thought of updating the height based on the number of rows (known height).

Re: Hieght of data grid, without scrollbars

Posted: Sun Jul 10, 2011 12:23 pm
by Klaus
Hi Gary,

for fields you can do:
...
set the height of fld X to the formattedheight of fld X
## same with width -> formattedwidth
...
But I did not find something similar for datagrids in the DataGrid docs.


Best

Klaus

Re: Hieght of data grid, without scrollbars

Posted: Sun Jul 10, 2011 12:36 pm
by doobox
Thank's Klaus,

This is almost as quick anyway, it just seemed at the start that it may have ended up a little long winded.

Code: Select all

 put the dgNumberOfLines of group "DataGrid 1" into tTempvar
   put tTempvar * 70 into tNewHeight
   set the height of group "DataGrid 1" to tNewHeight

Re: Hieght of data grid, without scrollbars

Posted: Fri Dec 30, 2011 1:59 pm
by strongbow
Try

the dgFormattedHeight of grp "YourDataGridName"

HTH

cheers

Alan