erich.wanker Posted June 6, 2013 Posted June 6, 2013 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 Quote
Oliver Morsch Posted June 6, 2013 Posted June 6, 2013 Use either TField.OnGetText() or a calculated field to change the text before displaying. Quote
Marlon Nardi Posted June 6, 2013 Posted June 6, 2013 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; 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.