请问:如何将DBGRID查询的结果中值小于0的数显示为红色,其他为黑色
解决方案 »
- Delphi怎样打印函数调用堆栈信息
- Delphi 与 ACCESS的诡异现象
- 救命!!!Field xxxx.xxxx does not have a corresponding component.Remove the declaration??
- TabControl1控件怎么用?
- 急啊,一个有两层明细表的问题 高手请看!
- 怎么写语句将TQuery1和TQuery2的数据合并
- 需要一个pascal的加密算法或控件!
- 谁知道哪里有可以访问MS OLAP Server多维数据库的Delphi控件?
- delphi中可以在运行时制定一个数组的长度吗,为什么/
- 我才学了一年的DELPHI,我还要学几年才可以成为真正的程序员?
- sos!急求帮助,提取htm格式文件中的表格信息,用于vfp调用重画表格
- 如何知道一个数是否在in一个动态数组中(不知数组的Length)?
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;Field: TField; State: TGridDrawState);
begin
if Table1.Fieldbyname(′Salary′).value<0 then
DBGrid1.Canvas.Brush.Color:=ColorGrid1.ForeGroundColor
DBGrid1.Canvas.Brush.Color:=ColorGrid1.BackGroundColor;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.TextOut(Rect.left+2,Rect.top+2,Field.AsString);
end;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
with DBGrid1.Canvas do
if Column.FieldName = 'FieldName' then // 要变颜色的字段名
if Column.Field.Value < 0 then begin
Font.Color := clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
DBGrid.Canvas.Font.Color := clRed
else
DBGrid.Canvas.Font.Color := clBlack;
DBGrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);