Topic: A grid with Images

Hello to all

I've made an application with MVD to manage a database about European insects.
It works very fine.

This application has a button calling a form allowing to perform searches according to various criteria (common name, latin, name, colors, food etc...

I had planned to present in an image container the illustrations of the insects found according to such criteria (for example, if I search for all red insects, display the images of all these red insects). Am I clear in my explanations?

Is it possible to obtain such a result? I tested several methods but they are too complex to implement.

Is there a simpler method of doing this?

if not, it does not matter, my application suits me perfectly (and other entomologists more confirmed than me)

Thank you in advance for your ideas

JB

Re: A grid with Images

can you attach your project?

Re: A grid with Images

You can show images in a TableGrid.

Dmitry.

4 (edited by derek 2018-09-28 12:12:52)

Re: A grid with Images

Hello Jean,
How are you?
I'm not sure what methods you have already tried but I think I would try it like this (sorry but my data is for aircraft, not insects (but the principle is identical)).
https://app.box.com/s/tjyz7448peqh3za0r5tn7gaxh0xniyah
Maybe this helps you?
Regards,
Derek.

Re: A grid with Images

Hello Derek and Dmitry

In fact, as usual I was doing a gaz factory to get a poor result.
So, I used a TableGrid as recommended by Dmitry and I applied your code very effective.
Everything works perfectly.
In fact, as usual I was doing a gas plant to get a poor result.
So, I used a TableGrid as recommended by Dmitry and I applied your code very effective. Everything works perfectly.

To finalize the set, I will add under each picture the name of the insect concerned.
Thanks again to both of you.

JB

6 (edited by derek 2018-09-29 17:59:58)

Re: A grid with Images

Hi Jean,
Yes, I did wonder about something like that - perhaps you can do it with hints (click on each image and the hint displays the name of the plane (or in your project, the name of the insect)).

procedure Form1_TableGrid2_OnCellClick (Sender: TObject; ACol, ARow: Integer);
begin
  form1.tablegrid2.hint := sqlexecute('select name from model where id =' +inttostr(form1.tablegrid2.dbitemid)); 
end;
Instead of clicking on each image, I think it would be much better if the hint displayed when the mouse moved over the image but I'm not sure what code you would use for that ('mouseover' works at the tablegrid level rather than at the row or cell level, I believe).
Anyway, here's a link if you want to have a look - https://app.box.com/s/d1psny2z30oilyb78bur6wttotnda7im

Regards,
Derek.

Re: A grid with Images

Hello Derek

Your idea will be a more confortable solution.

I have already seen this name display in a paid application managing videos (I think it was Movie Collector Pro) and I found it effective.

It showed the thumbnail of the movie and gave the name of the film when the mouse went over it

Now that you remind me that way, I'm going to use it, so it will save one cell for every image in the grid.

Thanks again for your help, very efficient as usual.

Regards

JB

Re: A grid with Images

Hello Derek

You're right.

I'have tried the code doesn't work at cell level.
Perhaps, will it be possible if an event OnMouseOver was implemented ?
But it is not a big affair !

The code you proposed is widely efficient for the goal aimed.

Thanks again

Regards

JB

Re: A grid with Images

Hello Derek

I adopted your idea of display images in a tablegrid with the hints.

But a change came to my mind.

Instead of displaying an image in the first cell of one grid and then another one in the first cell of the next line, and so on, it would be more economical in terms of visibility, to display images in contiguous cells each row.

Is it mandatory, in this case, to redraw each canvas of each cell with instructions like these ?

Form1.TableGrid1.Canvas.FillRect (Rect);
Form1.TableGrid1.Canvas.Draw (Rect.left, Rect.Top, My_Image)

I am interested in any idea going in this direction.

Thank you for your opinion in advance.

JB

10 (edited by derek 2018-10-10 16:04:21)

Re: A grid with Images

Hi Jean,
It sounds like you want a pivot table (like in Excel) but I don't think you can do anything like that very easily - I couldn't work out how to create the extra columns or delete columns depending on the number of rows in your grid.
Instead, perhaps you could use a series of images (I have used 5 in my example) and then scroll through them (so it makes it appear as if they are all in the same row of data);  this eliminates the problem of creating / deleting columns.
Also, instead of using 'hints', I now put a description below each of the scrolling images - perhaps it's better this way?
Anyway, please have a look at the attachment and see if it is of any help to you (the data is not relevant to your project but the principle is the same).
Regards,
Derek.

Post's attachments

Attachment icon jbimages.zip 971.56 kb, 484 downloads since 2018-10-10