Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Picture in grid control
Message
From
27/09/2002 05:23:33
 
 
To
26/09/2002 12:11:53
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00704581
Message ID:
00705101
Views:
16
Hi!

There is a trick to show all images in the column of grid with less code than you proposed to show a separate image on the form as user changes row :-) Also, there are situations when we need more space for grid (grid is horizontally scrolable and has a lot of columns), and image here is not a good when takes space outside of grid.

The trick is very simple:

Have a field in the grid record source containing filepath to the image. If images are stored some other way than in files, prepare images in temporary files.

In the form all you need is refresh image control inside of grid column for each grid row as it draws. You can do this by specifying your method or function call in one of the Dynamic* properties of the column. In the function change the Picture property of image control to the value from field. Grid will do all the rest. So, inthis case you will have, say, "thisform.RefreshPicture()" in DynamicFontBold property, and a form's RefreshPicture method:
thisform.MyGrid.MyImageColumn.Image1.Picture = allt(MyRecordSource.cPictFile)
return .F.
In certain cases image inside column should be wrapped into container to work properly. COlumn, of course, should have Sparse=.F. :-)

HTH.

>I believe you could work around the problems mentioned by resorting to the following trick:
>
>Place an image control on the form
>In the grid's afterrowcolchange event, put code to populate the image control with the image related to the record you are displaying.
>
>I have done this for a client who wanted to display pictures of his stock and it is very fast
>
>Here is an example of the code used:
>
>LPARAMETERS nColIndex
>
>local cCode
>cCode = alltrim(items.itemcode)
>theimage= 'C:\pictures\thumbnails\'+'TN_'+cCode+'.jpg'
>with thisform
> if file ('&theimage')
> with .Image1
> .visible = .t.
> .picture = theimage
> endwith
> else
> .Image1.visible = .f.
> endif
> .refresh
>endwith
>
>All your images would reside in a common directory and would have to have a code linked to the item code.
>
>The way this works is, as you navigate the grid, the item code is placed in a local variable, then it is integrated with the picture code and, if there is an image corresponding to the article, it is shown in the image control, placed on the form. The effect is the same and you do not have to burden your grid with special container controls and images, that would castigate performance to an unbearable level.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform