Images in Data Grids

Peter Haworth pete at lcsql.com
Mon Oct 29 17:36:21 EDT 2012


Hi Ronald,
I think Mark may be able to point you in the right direction better than I
on this since he seems to have at least figured out how to dynamically put
images into the datagrid, not sure about changing the image on the fly.

Here's another approach that might work using a table instead of a datagrid.

Let's say you have two columns in the table, one for the image and another
for the text you want your users to type into, and that somewhere in your
stack you have the images stored away.  When you load data into the table,
put a space into the first column of each line, then:

set the imagesource of char 1 of line x of field "yourtable" to the ID of
image "yourimage"

That will make the image appear in column 1 of your table.  You might also
need to set the textshift property of the char to make the image align
vertically the way you want it.

To detect when the user clicks on the image, put a mouseDown handler in the
table script:

on mouseDown
   *put* the imagesource of char (word 2 of the mouseCharChunk) of me
intotImageID
   switch tImageID
      case <an image ID>
         <whatever>
         break
      case <another image ID>
         <whatever>
         break
      case <etc>
         break
      default
         <if you get here, they didn't click on an image>
   end switch

If you need to change the imagesource when it's clicked, you can do it in
the case statements plus whatever else needs to happen.

Not sure what data you need to sort on but I'm sure that could be
accommodated.

Hope that helps,

Pete
lcSQL Software <http://www.lcsql.com>



On Mon, Oct 29, 2012 at 1:41 PM, Ronald Zellner <zellner at tamu.edu> wrote:

> That's correct, I want a different image in each row.
> These will be set at the beginning, but I do want the image source to
> change for each when it is first selected by the user.
> (Controlled by a card script called by the image)
> I thought of simply putting them in a group with a scroll bar, but I
> really need the sorting function so want to use the DataGrid.
>
> I'm still not clear on the method to place an image in the grid cell in
> the first place.
>
> Ron
>
>
>
> _______________________________________________
> 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