我在StringGridOnDrawCell事件的相应调度方法DrawCell进行覆盖,希望StringGrid在处理OnDrawCell事件前先进行一些操作,代码如下:
//声明部分:
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);Override;
//实现部分:
procedure TStringGridEx.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
var j: Integer;
begin
For j:= 1 To StringGrid1.ColCount-1 Do //j是列的索引
Begin
With StringGrid1.Canvas Do //想要在此让某一行颜色为兰。
Begin
Brush.Color:= clBlue;
Font.Color:= clBlack;
TextRect(ARect,ARect.Left,ARect.Top,StringGrid1.Cells[j,1]);
End;
End;
End;
inherited;
end;
//但结果是,整个StringGrid都变兰色了????请问哪里出错了??
//声明部分:
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);Override;
//实现部分:
procedure TStringGridEx.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
var j: Integer;
begin
For j:= 1 To StringGrid1.ColCount-1 Do //j是列的索引
Begin
With StringGrid1.Canvas Do //想要在此让某一行颜色为兰。
Begin
Brush.Color:= clBlue;
Font.Color:= clBlack;
TextRect(ARect,ARect.Left,ARect.Top,StringGrid1.Cells[j,1]);
End;
End;
End;
inherited;
end;
//但结果是,整个StringGrid都变兰色了????请问哪里出错了??
解决方案 »
- 如何禁止鼠标点击窗体的左上角,不弹出移动,关闭,最小化那个菜单啊!
- 如何将照片存入数据库?如何读取和显示?
- 一个数据库表结构的问题
- 加载动态链接库问题
- 各位网友,那位知道有一个专门讨论BusinessSkinForm的专门论坛?谢谢!
- 请问什么地方有delphi参考书下载。
- 这样的菜单怎么现实呀?:)
- ★★紧急任务!!!请问有没有能把Delphi转换为C++的软件?100分相送知情人!★★(老鱼)
- 哪儿有可以加背景图的TTrackBar控件下载,背景透明的也可以
- 在delphi中如何打开chm帮助文件?
- 有谁知道在Delphi中如何使用Formula one进行程序开发?
- to 斑竹,我有很多贴子打不开了,如何揭贴呀?
Begin
With StringGrid1.Canvas Do //想要在此让某一行颜色为兰。
Begin
Brush.Color:= clBlue;//改变的brush的颜色而没有改回。
Font.Color:= clBlack;
TextRect(ARect,ARect.Left,ARect.Top,StringGrid1.Cells[j,1]);
Brush.Color:= clWhite;改回白色。
End;
End;
我只是想让第一行显示兰色。
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);var j: Integer;
arect:trect;
begin
For j:= 1 To StringGrid1.ColCount-1 Do //j是列的索引
Begin
stringgrid1.FixedColor:=clblue;
stringgrid1.FixedCols:=0;
stringgrid1.FixedRows:=1; End;
End;
Begin
With StringGrid1.Canvas Do
Begin
Brush.Color:= clBlue; //这句有问题,把整个StringGrid1都变为蓝色了
Font.Color:= clBlack;
TextRect(ARect,ARect.Left,ARect.Top,StringGrid1.Cells[j,1]);
End;
End;