Good morning folks ...
I have a table in a SQLite database with a field of type "integer" to store "boolean" values. This field is linked, in the registration screen, to a DBCheckbox. So in order to check and uncheck the DBCheckbox, I had to write the OnGetText and OnSetText events of the field.
Now I need to show "Yes" and "No" values based on this field in a DBGrid. I wrote the code below on the OnDrawColumnCell event:
procedure TfrmPesquisar.dbgPesquisarDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Field = dsPesquisar.DataSet.FieldByName('claAtiva') then
begin
dbgPesquisar.Canvas.FillRect(Rect);
if Column.Field.AsString = '0' then
dbgPesquisar.Canvas.TextOut(Rect.Left+10,Rect.Top+3,'Não')
else
dbgPesquisar.Canvas.TextOut(Rect.Left+10,Rect.Top+3,'Sim');
end;
end;
However, only the first line is incorrectly displaying the value to be replaced (No) and the actual value (0 - zero), as shown below:
Has anyone ever had something similar or do you know the solution?
Thank you very much for the help.