风 风逍遥 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-14 #1 请问如何才能改变DBGrid中某一个格子(比如第3行第4列)的颜色(前景和背景)?请高手指点,谢谢。 在线等待![?]
T taninsh Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-14 #2 大概是在ondrawcolunm中处理吧 身边没有环境,要么给你测试一下
K kingdeezj Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-14 #3 http://www.delphibbs.com/delphibbs/dispq.asp?lid=409793
风 风逍遥 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-14 #4 我用如下代码,只能改变一行的前景色,答不到要求。 procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Table1.FieldByName('姓名').AsString:='张三' then DBGrid1.Canvas.Font.Color:=clRed; DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end;
我用如下代码,只能改变一行的前景色,答不到要求。 procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Table1.FieldByName('姓名').AsString:='张三' then DBGrid1.Canvas.Font.Color:=clRed; DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end;
风 风逍遥 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-14 #5 dq:用以上代码可以改变前景,背景可以改变吗? procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if (Column.Field.FieldName = 'GDBH') and (Column.Field.AsString = '200008') then DBGrid1.Canvas.Font.Color := clRed; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;//——俺用的是Delphi
dq:用以上代码可以改变前景,背景可以改变吗? procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if (Column.Field.FieldName = 'GDBH') and (Column.Field.AsString = '200008') then DBGrid1.Canvas.Font.Color := clRed; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;//——俺用的是Delphi