Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Grid Control

Grid Control

Grid Control

I am trying to create a gallery of graphical images which a user can scroll through using a grid control.

The form contains a grid with a single column with the current control being Image1 and Column1.Sparse = .F.

The controlsource for Image1 is GALLERY.filename where the field
GALLERY.filename contains the filename of the graphics file to be displayed.

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.

Can anyone help, please?

RE: Grid Control

I don't know what your other settings are like.  Try this to see how VFP sets them;  Add the table or view to the dataenvironment and drag the table to the form.  You can view the various property settings this way as a good way to learn.  The other good learning tool is to use the builder.  Right click the grid and choose builder

John Durbin

ICQ VFP ActiveList #73897253

RE: Grid Control


Tried your suggestions before asking this question. Were the Image1 controlsource be a general field rather the a filename reference, it would work.

A general field is not practical for all sorts of reasons.

Thanks for your input


RE: Grid Control

Hi Chris,
  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?


RE: Grid Control


In every row of the column


RE: Grid Control

Hi Chris,
  Sorry, I dont know.

  I couldnt get any consistent results in my testing.

  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).

  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.

Good luck.

RE: Grid Control


Your solution is what I already do, excepting that I use 12 images.

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.

Clearly it would be quicker to scroll through a grid than refresh the form each time you want to see more images.

However it may be that a grid with a table containing a large number of records would take far too long to initialise anyway.

I have asked this question on a number of forums and no one has yet come up with an answer.

I did ask the question on the Univeral Thread but for some reason, (perhaps not being a member?), it not not show.

Thanks for your input - this may simply be one of life's (FoxPro's) little mysteries!


RE: Grid Control

It crashed on me trying to recreate your grid.  Maybe cause of SP4 I don't know.  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.  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 <s>

What's wrong with the general field?  Size?  Can you do anything programmatically and erase it after?

You still have the listbox to fall back on.  Here's the help text from VFP:
Adding Pictures to Items in a List
You can set the Picture property of the list to the .bmp file you want displayed next to the items in the list.

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.

List box with pictures

The following code is associated with the Click event of the list box:

FOR iItem = 5 TO THIS.ListCount      && files start at the 5th item
   cExtension = UPPER(RIGHT(THIS.List(iItem),3))
      CASE cExtension = "DBF"
         THIS.Picture(iItem) = "tables.bmp"
      CASE cExtension = "BMP"
         THIS.Picture(iItem) = "other.bmp"
      CASE cExtension = "PRG"
         THIS.Picture(iItem) = "programs.bmp"
      CASE cExtension = "SCX"
         THIS.Picture(iItem) = "form.bmp"
         THIS.Picture(iItem) = IIF("]" $ cExtension, ;
            "", "textfile.bmp")

I believe the above bmps could be substituted with the contents from your field from each record

John Durbin

ICQ VFP ActiveList #73897253

RE: Grid Control

Chris: memo field rather that general with .bmp location might work, (if I understand your scenario?)

RE: Grid Control

He wants to view the pics insicde the grid if I understand him correctly

John Durbin

ICQ VFP ActiveList #73897253

RE: Grid Control


The code tried in the various events of the grid was -

  THISFORM.Grid1.Column1.Image1.Picture = GALLERY.filename

or THISFORM.Grid1.Column1.Image1.Picture = GALLERY.filename

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.

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.

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.

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.

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.

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.

The grid with an Image control would allow the user to select visually rather than by filename.

The current 12 thumbnails are in a page in a pageframe in the form GALLERY.
The user has an alternative "View" of the data in another page where a single Image control is refreshed by scrolling through a grid with GALLERY.filename as its ControlSource.

I have a feeling the current setup may yet be the best answer, but I would like someone to prove me wrong!

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%.

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.

If anyone is interested in learning more, email me at support@lithoplas.com


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close