Delphi 字段GetContentStyle不工作
我不知道为什么SQL Server Express 2014上不起作用:Delphi 字段GetContentStyle不工作,delphi,devexpress,tcxgrid,delphi-xe7,Delphi,Devexpress,Tcxgrid,Delphi Xe7,我不知道为什么SQL Server Express 2014上不起作用: procedure TMainForm.cxGrid1DBTableView1DONEStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; var AStyle: TcxStyle); var AColumn: TcxCustomGri
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。我不知道会出什么问题
数据库中的字段“完成”是“位”数据类型(数据库的sql server版本)
布尔字段)。值通常为0或1。
在cxGrid中,它是复选框类型。
Cxstyle1具有clRed颜色,cxstyle2具有clLime颜色
当应用程序运行中的所有字段(选中或未选中)时
该列为灰色。但只有当
复选框已选中!
我做错了什么吗?SQL Server位以布尔值的形式出现在Delphi中。尝试:
if ARecord.Values[AColumn.Index] then
AStyle := cxstyle1
else
AStyle := cxstyle2;
JohnS已经建议如何修复MSSQL,但您应该能够自己找到它-只需设置断点并检查实际值,然后将其与“0”进行比较。