我用StringGrid显示数据库种数据,当有一些特殊数据的时候,需要把StringGrid中的某几行的颜色设成特定的颜色,如何实现,谢谢。
解决方案 »
- 马上结~~~
- **************大量精品代码整理发布。。。。。。(不断收集中)*******************(
- 求access设计的列车票务系统数据库或其设计思想
- 连老师也解决不了的数据库问题!大家切磋一下吧
- 哪位高手帮我把这段代码做注释,能不能改为遇到回车换行就结束的拷贝。
- 每个月,总有那么一两个令人心烦的问题。这个月的问题如下:
- 今天发现有人用程序进行签名(转)
- Table与dbgrid间发生的怪现象
- 高分求救:能够实现字幕渐出的完整程序(回答者均有分)
- 请问如何让DELPHI编的程序带参数运行?谢谢!
- Borland Delphi 7 Studio Enterprise 注册码,序列号
- 怎样使TrackBar实现鼠标点到哪个位置划块就到哪个位置呢
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1 do
with Canvas do
begin
FillRect(Rect);
if StrToFloat(Cells[1,2]) > 2000 then //如果数据大于2000则设置字体为红色
Font.Color := clRed
else Font.Color := clBlack;
DrawText(Handle, PChar(Cells[ACol, ARow]), Length(Cells[ACol, ARow]),
Rect, DT_LEFT+DT_SINGLELINE+DT_VCENTER);
end;
end;
end;
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1 do
with Canvas do
begin
FillRect(Rect);
if StrToFloat(Cells[1,2]) > 2000 then //如果数据大于2000则设置字体为红色
Font.Color := clRed
else Font.Color := clBlack;
DrawText(Handle, PChar(Cells[ACol, ARow]), Length(Cells[ACol, ARow]),
Rect, DT_LEFT+DT_SINGLELINE+DT_VCENTER);
end;
end;
将deafultDrawing设:false;在OnDrawCell写下:
if ARow=2 then
begin
StringGrid1.Canvas.Brush.Color:=clRed;
StringGrid1.Canvas.FillRect(Rect);
end;
将清空单元格的值,
加上
TextOut(Rect.Left+2, Rect.Top+3, StringGrid1.Cells[ACol, ARow]);