如何让dbgrideh的某一个单元格根据条件显示特定颜色,GetCellParams好像只能让整行或者整列变色
解决方案 »
- delphi程序编译出错. [Error] Unit1.pas(74): Declaration of 'training' differs from previous declaration
- 问个ADSL建立TCP/IP连接的问题
- 使用dbexpress链接mysql的问题
- 两个按钮button的onclick事件,怎么区分呀??? 在线在等侍。。。。。
- 关于数据库连接的登陆窗口
- 怎样写一个函数判断一个字符串是否日期类型(如2003-10-20)
- 有书下!http://www.dingbing.com/ebook.htm ,http://www.dingbing.com/
- 如何在系统找一个进程。加急!!!100分
- 怎样屏蔽CTRL+ATL+DEL?
- 以下是一段网游的喊话调用过程,我调用后,为什么发汉字出现显示乱码,而发字母和数字则只能发第一个字?
- 在使用 ServerSocket和多个ClientSocket通讯 进行有选择的发送给不同的 ClientSocket 怎样做最好
- 如何在image中用鼠标选定一个长方形的区域,区域内的图像在另一个image中显示?在线等待...急
procedure TFormAutoCal.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if trim(StringGrid1.Cells[4,ARow]) = '废标' then
with stringgrid1 do
begin
canvas.Brush.color:= clRed;
canvas.Font.Color := clWhite;
canvas.FillRect(Rect);
canvas.TextOut(rect.left+2,rect.top+2,cells[acol,arow])
end;
if trim(StringGrid1.Cells[4,ARow]) = '未投标' then
with stringgrid1 do
begin
canvas.Brush.color:=clblue;
canvas.Font.Color := clWhite;
canvas.FillRect(Rect);
canvas.TextOut(rect.left+2,rect.top+2,cells[acol,arow])
end;
end;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
valX, valY :Integer;
valStr :String;
begin
with TDBGrid(Sender) do
begin
if ((State = [gdSelected]) or (State=[gdSelected,gdFocused])) then
begin
Canvas.Font.Color :=clWhite;
Canvas.Brush.Color :=$00C08080;
end
else
begin
if DataModuleSQL.ADOQuerySQL.RecNo mod 2<>0 then
begin
Canvas.Brush.Color :=clWhite
end
else
begin
Canvas.Brush.Color :=$00CFFEFD;
end;
end; DefaultDrawColumnCell(Rect, DataCol, Column, State); case DataCol of
1:
begin
case (DataModuleSQL.ADOQuerySQL.FieldByName('频道').AsInteger) of
1:
begin
valStr := '频道 1';
end;
2:
begin
valStr := '频道 2';
end;
end; valX := ((Rect.Left + Rect.Right)
- Canvas.TextWidth(valStr)) div 2;
valY := ((Rect.Top + Rect.Bottom)
- Canvas.TextHeight(valStr)) div 2;
Canvas.Brush.Color :=clRed;
Canvas.TextOut(valX, valY, valStr);
end;
......
end;
end;
end;
时间 是否预计
12:00 true
13:00 false
根据是否预计字段来确定时间字段的字体颜色
AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
if column.FieldName = '时间' then
if dbgrideh1.datasource.dataset.FieldByName('是否预计').asstring='true' then
AFont.Color:= clRed
else
AFont.Color:= clBlue;
end;