Page 1 of 1

DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 6:51 pm
by Gage
Where does the list of integers in the pControlRect parameter that is passed to the LayouControl handler in a DataGrid "Form" come from?

I am running into significant trouble trying to get my rows to lay out properly, and after using the variable watcher, I am noticing that the height of the rectangle bounded by the integers in the pControlRect param are not equal to the height of the row template I am using, resulting in some of the objects in the row template being cut off when the DataGrid builds the interface.

I realize that I could use some mathematical operations to correct this each time, but somehow, each subsequent start point is based off of an incorrect number, and I think I would have to do some really complicated math to incrementally correct the rect every time a new record display is built.

Hoping there is a quick fix or bit of information that will clarify my understanding, so I can be sure that a correctly-sized rect is being passed into the LayoutControl handler each time it goes to create a row.

Thanks in advance,
Phil E.

Re: DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 7:05 pm
by Klaus
Hi Phil,

maybe this one helps, it is from the "DataGrid" PDF, which is the only doc about datagrids.
Get it here: http://lessons.runrev.com/m/datagrid
...
LayoutControl pControlRect
- LayoutControl is sent to your custom template when it is time to position all of the controls. pControlRect is the rectangle that the data grid has resized your control to. This is useful for knowing the left (item 1 of pControlRect), top (item 2 of pControlRect), right (item 3 of pControlRect) and bottom (item 4 of pControlRect) bounds you can position controls at. Note that if you have a data grid form that does not have fixed height set to true then you can ignore the botom (item 4 of pControlRect) and make your control as tall as you need.
...

Best

Klaus

Re: DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 7:15 pm
by Gage
Hi, Klaus!

Yes, I have been poring over that collection of information for almost two weeks now trying to gain as much insight as possible. Thanks!

I am making a very simple grid to fully understand the goings-on, so fixed height is true.

Now, I still don't understand why items 2 and 4 (the top and bottom) of my pControlRect are incorrect.

Items 1 and 3 appear to be correct.

Here is the problem: my row template is 43 pixels tall, in order to accommodate a "Title" field above an "Info" field (which for the purposes of this stack only has one short word in it), but the pControlRect the DataGrid wants to repeatedly use only has a height difference of 21 pixels (item 4 minus item 2 always equals 21, even as the values update to locate the next record).

So, the pControlRect wants to let me use 21 pixels of height for each record, when I really need it to give me 43. This results in the "Info" field not being displayed. The next record's "Title" field is displayed, but since the grid wants to place the top of the subsequent record only 21 pixels below the top of the preceding record, everything below the 21st pixel is not shown. This happens for every record displayed.

I do not understand why the pControlRect height boundaries are incorrect; shouldn't they be using the height information in my row template?

Hope that is all clear!
Phil E.

Re: DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 7:33 pm
by Gage
OK,

I unchecked the fixed row height box, and it appears now to be working.

For my sanity, why on earth is this the case?

Each of my rows have the same height, so it should be 100% fine if the height is fixed. Or am I misunderstanding what the property means?

Does turning the fixed height property 'on' simply mean a default height is used every time, and that default is 21 pixels? I would have thought that "Fixed" height meant it cannot change from one record to the next, but it will size itself to be the CORRECT not-changing height.

Please enlighten me!
Phil E.

Re: DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 7:39 pm
by Gage
OK,

Looks like I am jumping the gun with my posts. Correcting the issue has to do with the fixed row height property value of the datagrid. It is indeed set at 21 by default, and having the fixed row height set to true is indeed OK, I just needed to place the correct value in the field next to it.

This clears it all up, and I do hope that my being so verbose on the problem will help anyone else who has the same problem learn the solution.

Cheers!
Phil E.

Re: DataGrid LayoutControl Handler

Posted: Wed May 22, 2013 9:49 pm
by Klaus
Hi Phil,

glad you got it sorted out!


Best

Klaus