DataGrid column update and button center

Scott Morrow scott at
Mon Aug 9 06:03:37 CDT 2010

Thank you, Mr. Slug. Your helpful observations about my beginning efforts with the data grid are much appreciated.

On Aug 9, 2010, at 3:38 AM, zryip theSlug wrote:

> On Fri, Aug 6, 2010 at 12:02 PM, Scott Morrow
> <scott at> wrote:
> Hi Scott,
>> Two Data Grid questions:
>> 1)     I'm updating a single column of a Data Grid table.  I can't discover any other way than to loop through each index.  Would this be the accepted method?
>> --- the code I'm using -------------------------------------------
>> put the dgData["false"] of grp "DataGrid 1" into tArray
>> put 1 into tIndexCounter
>>  -- the column data might look like this as I'm setting the hilite of checkBox buttons
>> put "true,true,false,true" into tNewColumnData
>> repeat for each item tNewData in tNewColumnData
>>     put tNewData into tArray[tIndexCounter]["theColumnName"]
>>     add 1 to tIndexCounter
>> end repeat
>> set the dgData of grp "DataGrid 1" of stack "myStackName" to  tArray
>> ---------------------------------------------------------------------
> Using a loop is the only way I know.
> You can also update the array by using the DataGrid API, with the
> SetDataOfIndex (or SetDataOfLine).
> It is equivalent to your loop excepted that you have not to refresh
> the whole data, only the data required by the column.
> It means that by using the SetDataOfIndex, set the dgData of the DG is
> not required.
> Note that in this line
> put the dgData["false"] of grp "DataGrid 1" into tArray
> the dgData properties not accepts a parameter. Only dgText do.
>> 2)     I have a column of checkbox buttons.  The column header is wider than the
>> button(s) and I would like to be able to center the button(s) in the column.  It seems like I
>> should be able to do this (using the DataGrid inspector) by setting the
>> dgColumnAlignment to "center" but I'm not having any luck.  Any suggestions (hoping I
>> don't need to switch to a "form" layout"  :  )
> The dgColumnAlignment is only provided to change the alignment of a
> standard column (text and not managed by a custom behavior)
> To "center" a checkbox, you have to manage it in the LayoutControl
> event of the column behavior.
> on LayoutControl  pControlRect
>    centerMyCheckBox -- center the checkbox in the rect (pControlRect)
> of the cell
> end LayoutControl
> So no need to switch to a DG form ;)
> Regards,
> -- 
> -Zryip TheSlug- wish you the best! 8)
> _______________________________________________
> use-revolution mailing list
> use-revolution at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the use-livecode mailing list