Jump to content

uniDBGrid - DrawColumnCell - to draw a image ...


erich.wanker

Recommended Posts

hello,

 

i have [ ZConnection -  ZQuery -  DataSource -  uniDBGrid ]   to a firebird SQL Database..

 

 

i try to draw two different Images in the grid if a value is "0" or "1" in field "IMAGE_TEXT" of type char(200)

 

i tryed out:

 

procedure UniDBGrid3DrawColumnCell(Sender: TObject; ACol,
  ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin


if column.FieldName ='IMAGE_TEXT' then
begin
  if column.Field.Text ='0' then column.Field.Text:='<img width=16 height=16 src="images/a.png"/>';
  if column.Field.Text ='1' then column.Field.Text:='<img width=16 height=16 src="images/b.png"/>';
end;

but it allways wants to edit the database - or makes errors .... or 

 

whats the right way to realise this ?

 

Thank you for your help.

Erich

 

Link to comment
Share on other sites

use your estrtura the event OnGetText.

 

ex:

 

procedure TFormCUSTOS_Remanejamento_Orcamentario.CDSDestinoIMG_SITUACAOGetText(
  Sender: TField; var Text: string; DisplayText: Boolean);
begin
  if CDSDestino.FieldByName('SITUACAO').AsString = 'A' then
    Text:= '<img src="../imagens/confirmado.png" width=16 height=16 align="center" />';
  if CDSDestino.FieldByName('SITUACAO').AsString = 'R' then
    Text:= '<img src="../imagens/negado.png" width=16 height=16 align="center" />';
  if CDSDestino.FieldByName('SITUACAO').AsString = EmptyStr then
    Text:= EmptyStr;
end;

 

 

 

  • Upvote 1
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.

Guest
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...