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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grid items related to image display 1

Status
Not open for further replies.

foxup

Programmer
Dec 14, 2010
328
CA
Hi,

I have a grid (from a controlsource.dbf) on my form where what I would like is that as the user scrolls down the records in the grid, the "IMAGE" to the left of the grid (image1) changes according to the value in the field. For example: If the field is a "router", show the image of that router to the left. If the image is a modem, show the image of that modem to left.

Any ideas? Can this be done? Please help.

Thanks,
FOXUP!
 
I'm not sure if I mentioned it but the image1 is not part of the grid, it is to the left of the grid. Thanks. :)
 
You need to add code to the grid's AfterRowColChange event.

The code simply needs to change the Picture property of the image control to reflect the contents of the relevant field. Something like this:

Code:
* In the grid's AfterRowColChange
thisform.Image1.Picture = MyAlias.Imagefield

where MyAlias is the alias of the controlling table, and Imagefield is the name of the field that holds the name of the image.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Put the logic in AfterRowColChange event of the grid.
Let say you have all pictures for them somewhere and the value of the field match the name of the picture:
Code:
*** ARCC event of the grid
IF NOT thisform.Image.Picture == FORCEEXT(Field1,"JPG")
   thisform.Image.Picture = FORCEEXT(Field1,"JPG") && You can use BMP or whatever
   thisform.Image.Refresh()
ENDIF

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
The image is NOT part of the grid. It is an image to the left of the grid. That doesn't seem to work.

Please help.

Thanks,
FOXUP!
 
I haven't done this myself, but it does not seem too difficult.

On your form put a Container object to the left of your Grid to display the picture.

In your Grid's control cursor, you would likely have a field containing the fully pathed filename of the associated picture.

Then in the Grid's AfterRowColChange method you would 'harvest' the fully pathed picture filename and use it to change the Container's Picture property. You may have to use a ThisForm.Container1.Refresh.

Good Luck,
JRB-Bldr
 
Wow, between the time I began entering my post and when I hit Submit - 3 other people also entered their posts.

That's service for you.

Good Luck,
JRB-Bldr
 
We ALL understand that the image is NOT a part of the grid.
If it IS part of the grid, then the solution would be different.
But our crystal balls didn't work today :) (As Marcia Akins used to say).
How do you know which picture to show?
How pictures are related with the table you use as RecordSource of the grid?

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
My Mistake. I had VISIBLE=.F. arrrrggg!!!

Got it. Thanks Mike & all.

FOXUP!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top