Fields GetContentStyle not working

779 views Asked by At

I dont know why this is not working on SQL Server Express 2014 :

procedure TMainForm.cxGrid1DBTableView1DONEStylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
  var AColumn: TcxCustomGridTableItem;
begin
AColumn := (Sender as TcxGridDBTableView).GetColumnByFieldName('DONE');
if  VarToStr(ARecord.Values[AColumn.Index]) = '0' then
AStyle := cxstyle1 else AStyle := cxstyle2;
end;

It works on SQLite,Firebird,Accuracer,Absolute Database... but not on SQL Server Express 2014. And I dont know what could be wrong.

The field 'DONE', in the database, is 'bit' datatype (sql server version of a boolean field).Values are usually 0 or 1. In cxGrid it's checkbox type. Cxstyle1 has color clRed and cxstyle2 has color clLime.

When the application runs all the fields (checked or unchecked)in the column are colored clLime.But they should be colored that way only if the checkbox is checked ! Anything I am doing wrong ?

1

There are 1 answers

0
JohnS On BEST ANSWER

The SQL Server BIT comes to Delphi as a Boolean. Try:

if ARecord.Values[AColumn.Index] then
  AStyle := cxstyle1 
else 
  AStyle := cxstyle2;