Fields GetContentStyle不起作用

时间:2014-11-10 02:08:53

标签: delphi devexpress tcxgrid delphi-xe7

我不知道为什么这不适用于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;

它适用于SQLite,Firebird,Accuracer,绝对数据库......但不是 SQL Server Express 2014.我不知道可能出现什么问题。

数据库中的字段' DONE'是' bit'数据类型(sql server版本的 boolean field).Values通常为0或1。 在cxGrid中它的复选框类型。 Cxstyle1的颜色为clRed,cxstyle2的颜色为clLime。

当应用程序运行所有字段(已选中或未选中)时 该列的颜色为clLime.But它们应该以这种方式着色 选中复选框! 我做错了什么?

1 个答案:

答案 0 :(得分:0)

SQL Server BIT作为布尔值来到Delphi。尝试:

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