Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Control

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
I am trying to create a gallery of graphical images which a user can scroll through using a grid control.<br><br>The form contains a grid with a single column with the current control being Image1 and Column1.Sparse = .F. <br><br>The controlsource for Image1 is GALLERY.filename where the field <br>GALLERY.filename contains the filename of the graphics file to be displayed.<br><br>I have tried all sorts of ways to force the grid to display the graphics file called by GALLERY.filename, but it will only ever display the first record's graphics file.<br><br>Can anyone help, please?<br>
 
I don't know what your other settings are like.&nbsp;&nbsp;Try this to see how VFP sets them;&nbsp;&nbsp;Add the table or view to the dataenvironment and drag the table to the form.&nbsp;&nbsp;You can view the various property settings this way as a good way to learn.&nbsp;&nbsp;The other good learning tool is to use the builder.&nbsp;&nbsp;Right click the grid and choose builder<br> <p>John Durbin<br><a href=mailto: > </a><br><a href= > </a><br>ICQ VFP ActiveList #73897253
 
John<br><br>Tried your suggestions before asking this question. Were the Image1 controlsource be a general field rather the a filename reference, it would work.<br><br>A general field is not practical for all sorts of reasons.<br><br>Thanks for your input<br><br>Chris
 
Hi Chris,<br>&nbsp;&nbsp;When you say 'it will only ever display the first record's graphics file', do you mean it displays the first record's graphics file in every row of the column, or only in the first row of the column?<br><br>Jon
 
Hi Chris,<br>&nbsp;&nbsp;Sorry, I dont know.<br><br>&nbsp;&nbsp;I couldnt get any consistent results in my testing.<br><br>&nbsp;&nbsp;The way I present image galleries is by placing X number of image controls on a form (usually 9) and place previous and next command buttons under the images and when they click the next button, I just reset the image.picture property to the next 9 images(the file paths are usually stored in a table, similar to yours).<br><br>&nbsp;&nbsp;If you have to use a grid, post your message on UniversalThread.com, and you should have a resolution by the end of the day.<br><br>Good luck.<br>Jon
 
Jon<br><br>Your solution is what I already do, excepting that I use 12 images.<br><br>The advantage of the separate images form is that you can identify each thumbnail with a label underneath it, and this does give it the look and feel of a gallery.<br><br>Clearly it would be quicker to scroll through a grid than refresh the form each time you want to see more images. <br><br>However it may be that a grid with a table containing a large number of records would take far too long to initialise anyway.<br><br>I have asked this question on a number of forums and no one has yet come up with an answer.<br><br>I did ask the question on the Univeral Thread but for some reason, (perhaps not being a member?), it not not show.<br><br>Thanks for your input - this may simply be one of life's (FoxPro's) little mysteries!<br><br>Chris
 
It crashed on me trying to recreate your grid.&nbsp;&nbsp;Maybe cause of SP4 I don't know.&nbsp;&nbsp;You have to specify the picture property of the image so no matter how many records you have represented in your grid, only one picutre can be shown I believe.&nbsp;&nbsp;Even if you can in theory say pic = eval(myfieldwithpath) it is still just one and the same pic, you're still stuck since the image control dun't have no recordsource &lt;s&gt;<br><br>What's wrong with the general field?&nbsp;&nbsp;Size?&nbsp;&nbsp;Can you do anything programmatically and erase it after?<br><br>You still have the listbox to fall back on.&nbsp;&nbsp;Here's the help text from VFP:<br>Adding Pictures to Items in a List<br>You can set the Picture property of the list to the .bmp file you want displayed next to the items in the list.<br><br>For example, you could have a list box populated with files. You might want to have a different bitmap next to the file if it is a table, a program, or some other file type.<br><br>List box with pictures<br><br>The following code is associated with the Click event of the list box:<br><br>FOR iItem = 5 TO THIS.ListCount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&& files start at the 5th item<br>&nbsp;&nbsp;&nbsp;cExtension = UPPER(RIGHT(THIS.List(iItem),3))<br>&nbsp;&nbsp;&nbsp;DO CASE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CASE cExtension = &quot;DBF&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THIS.Picture(iItem) = &quot;tables.bmp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CASE cExtension = &quot;BMP&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THIS.Picture(iItem) = &quot;other.bmp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CASE cExtension = &quot;PRG&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THIS.Picture(iItem) = &quot;programs.bmp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CASE cExtension = &quot;SCX&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THIS.Picture(iItem) = &quot;form.bmp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OTHERWISE <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THIS.Picture(iItem) = IIF(&quot;]&quot; $ cExtension, ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;, &quot;textfile.bmp&quot;)<br>&nbsp;&nbsp;&nbsp;ENDCASE<br>ENDFOR<br><br>I believe the above bmps could be substituted with the contents from your field from each record<br> <p>John Durbin<br><a href=mailto: > </a><br><a href= > </a><br>ICQ VFP ActiveList #73897253
 
Chris: memo field rather that general with .bmp location might work, (if I understand your scenario?)
 
He wants to view the pics insicde the grid if I understand him correctly <p>John Durbin<br><a href=mailto: > </a><br><a href= > </a><br>ICQ VFP ActiveList #73897253
 
Jon<br><br>The code tried in the various events of the grid was - <br><br>SCAN <br>&nbsp;&nbsp;THISFORM.Grid1.Column1.Image1.Picture = GALLERY.filename<br>ENDSCAN<br><br>or THISFORM.Grid1.Column1.Image1.Picture = GALLERY.filename<br><br>Unfortunately listbox controls do not have a stretch property which needs to be set to Isometric as the files, (.jpg by default), may be of any size.<br><br>A general field is inappropriate as the table GALLERY is created in the LOAD method of the form called GALLERY. The table is populated using ADIR() from a folder called ..\gallery, filtering out any invalid files.<br><br>It would then mean SCAN APPEND GENERAL etc to initialise the form, followed by the grid initialisation, all of which would take a donkey's age.<br><br>A full sized single graphics file is used in the main form as a background to reports which the user can interactively modify and save at runtime using a toolbar class.<br><br>The gallery provides files which the user can drag and drop onto the main form, or alternatively drag and drop files onto the main form from elsewhere on the system using Windows Explorer.<br><br>Thus the ..\gallery files are subject to editing by external graphics editors, addition and deletion and experience shows embedding them in a general field is impractical and creating a new table every time the form runs ensures the data is valid.<br><br>The grid with an Image control would allow the user to select visually rather than by filename.<br><br>The current 12 thumbnails are in a page in a pageframe in the form GALLERY. <br>The user has an alternative &quot;View&quot; of the data in another page where a single Image control is refreshed by scrolling through a grid with GALLERY.filename as its ControlSource.<br><br>I have a feeling the current setup may yet be the best answer, but I would like someone to prove me wrong!<br><br>One of the side issues of this project has been the inability of the FoxPro report preview to correctly display graphic images when they are less than 100%. <br><br>I have created a form which acts a report preview screen by opening the report as table, scanning the table and using the data to set the properties of the form's controls, thus ensuring accurate previewing. Using a toolbar class, the form can then offer different views such as whole page, 75%, page width etc. <br><br>If anyone is interested in learning more, email me at <A HREF="mailto:support@lithoplas.com">support@lithoplas.com</A><br><br>Chris<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top