Image Controls in a Datagrid

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Image Controls in a Datagrid

Post by xclntdesign » Fri Aug 26, 2011 8:36 pm

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.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Image Controls in a Datagrid

Post by BarrySumpter » Sun Sep 25, 2011 1:16 pm

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
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Image Controls in a Datagrid

Post by Klaus » Sun Sep 25, 2011 2:08 pm

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

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Image Controls in a Datagrid

Post by BarrySumpter » Sun Sep 25, 2011 10:47 pm

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)
Last edited by BarrySumpter on Mon Sep 26, 2011 1:47 am, edited 3 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Image Controls in a Datagrid

Post by BarrySumpter » Sun Sep 25, 2011 11:21 pm

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.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply