Page 1 of 1

Image Controls in a Datagrid

Posted: Fri Aug 26, 2011 8:36 pm
by xclntdesign
I am trying to add images to push buttons inside a Datagrid Form, and have run into a bit a problem.

While editing the Row Template for my Datagrid, I have tried my usual method of importing the image as a control and hiding it. Then I select the icons & Border menu of the Object Inspector, change the image library to "This Stack" to find my icon. But its not there. I have tried importing in both the Row Template and the screen before it that tells you how to edit a Row Template, and neither work.

My workaround was to create a new image library, which I called Button Library. I can now find and select the proper icon image inside the Datagrid. The problem I run into with that is when creating a standalone on another machine (originally designed on a PC, now porting to Mac), the icons in the Button Library are not saved with the standalone. I've tried adding the images to the Copy Files section of my standalone settings, and that has not fixed the issue.

Does anyone have a possible solution that will allow me add image controls to Datagrid AND get them to save in the standalone?

Thanks in advance.

Re: Image Controls in a Datagrid

Posted: Sun Sep 25, 2011 1:16 pm
by BarrySumpter
I drop my images into the Row Template.
Then ID them from 10000 onward.
Then use the Column Behaviour to assign the images per row.

hth

Re: Image Controls in a Datagrid

Posted: Sun Sep 25, 2011 2:08 pm
by Klaus
Hi guys,

since I try not to rely on not so reliable LiveCode mechanisms :D
I usually import all of my images on ONE card that the user never sees.

OK, I will have to note their IDs manually, but this way I can be sure
that all images are there in the standalone!

And I always use buttons to display images, especially in DataGrids,
even if they do not act as a button.

I strongly advice to NOT copy any image into the "template" row!
Use a button instead!

Remember that the DataGrid behavior will COPY the "template group"
into the datagrid for each row and so you will end with lots of copies of
the original image, which will have of course different IDs!

Hope that helps.


Best

Klaus

Re: Image Controls in a Datagrid

Posted: Sun Sep 25, 2011 10:47 pm
by BarrySumpter
I use buttons in the row and set the button to Style: Transparent
Then use its Icon to set its Image.

Since I only have two small images of WhiteSquareOn or WhiteSquareOff I import them into my Row Template.
Noted: Klaus' suggestion to place them instead on my resources sub-stack.

ADDITONAL NOTE:
I've just had a play around and the only way I could get my button icon to change using my image ID in the Row Script Behaviour was if the image itself was part of the template card Group. I don't know why.

And in the row behaviour script (since a DataGrid form scrolls smoother than a data grid table).

Code: Select all

on FillInData pAryRowData
...
   tWhiteSquareOffPNGID = 10000
   tWhiteSquareOnPNGID = 10001
...
   set the icon of btn "CheckBox_PNG" of me to tWhiteSquareOnPNGID
...
Also experimenting with Images:

Code: Select all

on FillInData pAryRowData
...
   put the image "optWhiteSquareOn.png" into image "Option_PNG" of me
...
Note: I did read somewhere that using buttons instead of images is more efficient.
.......Something like a button icon points to an image but an image holds another full copy of the image.
.......Hence No: set the imageID of image1 to 10001
.......(??? could be wrong here. Had all kinds of probs working with images)

Re: Image Controls in a Datagrid

Posted: Sun Sep 25, 2011 11:21 pm
by BarrySumpter
I've always wondered if the group _DataGridTemplateInstructions_
gets repeated for each row as well and if it should be removed.

Or if only the objects within the group "DataGrid 1" of the Row Template are repeated for each row.
i.e. the images are NOT part of the group "DataGrid 1" of Row Template.