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

Displaying a photo in a control 1

Status
Not open for further replies.

ulises48

Technical User
Feb 3, 2012
17
MX
Hello all and thank you in advance for your time.
I'll try to be as specific as possible in my question.
Basically,I have a PRODUCTS table. I want a form with a combobox that displays a list of all the products in the PRODUCTS table and when selecting one, a PHOTO of it is displayed in a control in the form.
What modification do I need to make to my PRODUCTS table?
What code do I need to write in my combobox control?
Please be as specific as possible, as I am not an expert.

Again, thank you in advance.

Ulises
 
Hi Ulises,

Re modifications to your Products table. All you need is a field to hold the name of the image file. If all the images are in the same folder, you just need the filename. If they are in different folders, you will need the entire path (or a relative path).

On the form, place an Image control. Make it the right size, and set it's Stretch property as appropriate.

In the InteractiveChange of the combo box, write code that locates the appropriate record in the Products table (you won't need to do that if you are using RowSource = 6 for the combo box). Then set the Picture property of the Image control to the contents of the field that holds the filename.

Here is some very approximate code:

Code:
* InteractiveChange of combo box

* Locate record corresponding to selected item in combo
* (I'll leave you to do that).

* Assuming the Filename field in Products holds the filename
* of the image file, and this is in your app's search path:
THISFORM.Image1.Picture = Products.Filename

That's basically all there is to it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Well thanks so much Mike for your prompt and clear response. I am not at my work computer at the moment, but will try that as soon as I get there.
Again, much obliged.

Ulises
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top