How to resize the columns of a datagrid?

Mike Bonner bonnmike at gmail.com
Tue Aug 4 16:31:00 EDT 2015


If you want proportional, all the same size relative to each other,
something like this in the card script should work.

on resizestack
   set the rect of group 1 to the rect of this card -- set your dg group to
whatever new size you want
   resizecol
end resizestack
on resizecol
      put the  width of group 1 into tWidth
      put the dgProp[ "columns" ] of group 1 into tCol
      put trunc((the effective width of group 1) / (the number of lines in
tCol)) into tWidth

      repeat for each line tLine in tCol
         set the dgColumnWidth[tLine] of group 1 to tWidth
      end repeat

end resizecol

It does a pretty good job, but it leaves the horizontal scroll bar up. I'm
sure you could nudge things around so that there was no scroll bar (or just
turn that one off)

If you want different sizes, all changing proportionally, you'll need to do
as sri said and adjust based on a factor. (it should be easy enough to
store the size of each column as a percentage of total width and use that
to generate your widths)

On Tue, Aug 4, 2015 at 9:26 AM, Klaus major-k <klaus at major-k.de> wrote:

> Hi Tiemo,
>
> > Am 04.08.2015 um 17:10 schrieb Tiemo Hollmann TB <toolbook at kestner.de>:
> >
> > Hi Bob,
> > are you thinking of "dgColumnIsResizable"? It allows the user to resize
> > manually the column width.
> > Or do you have another property in mind?
>
> I’m obviously not Bob, but I think he was more thinking of something like:
>> ## Set width of single column:
> set the dgColumnWidth[„Name of column"] of group "DataGrid" to 150
> ..
> ## Set width of all columns, supply a COMMA delimited list of desired
> widths:
> set the dgProps["column widths"] of group "DataGrid" to „200,200,150,300"
>> :-)
>
> > Tiemo
> >
> > -----Ursprüngliche Nachricht-----
> > Von: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] Im
> Auftrag
> > von Bob Sneidar
> > Gesendet: Dienstag, 4. August 2015 16:08
> > An: How to use LiveCode <use-livecode at lists.runrev.com>
> > Betreff: RE: How to resize the columns of a datagrid?
> >
> > There's a dgprop for it. Check documentation.
>
> Best
>
> Klaus
>
> --
> Klaus Major
> http://www.major-k.de
> klaus at major-k.de
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list