Jump to content

Draw images in a cell column depending on its value


Recommended Posts

Hi all, I'm trying to draw images in a column, depending the value of a cell. I don't have a client dataset, but a uniDBGrid, a datasource and a TAdoquery. I want reproduce something as shown in attached pictures (see column 'Stato').



Is possible to do do something similar with Unigui?


Link to comment
Share on other sites

  • 11 months later...

Hello Marco, can you post your code here? I have the same requirement.


1. add a calculated field of type string and f.e. size 80. If you have a field "aktiv" with type integer name the new field "calc_aktiv" or what you like.


2. In the OnGetText event of this new field manage the HTML-output for the image:


procedure TDataModule1.Query_KontaktListcalc_aktivGetText(Sender: TField;

  var Text: string; DisplayText: Boolean);


  with sender.Dataset do begin

    case fieldbyname('aktiv').value of

       0: text:= '<img width=16 height=16 src="/images/res_red.bmp"/>';

       1: text:= '<img width=16 height=16 src="/images/res_green.bmp"/>';





3. Add a column to your grid with the field "calc_aktiv".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...