?
解决方案 »
- TSQLStoredProc调用MYSQL存储过程出错
- 自我感觉比较奇怪的一个问题: 怎样用程序判断当前系统的电脑是台式机还是笔记本?
- 送分问题:这个SQL语句怎么写?
- 关于IdFTP的Get方法
- 有谁可以告诉我如何在DELPHI里实现DBGRID中内容的打印,还有计算两个CTIME类型值的相差天数
- 300分:网络校时
- 求助Delphi7 TTable的DatabaseName属性中怎么没有自己定义的那个数据库名字?求高手解答
- C到delphi的变化???
- delphi做控件的问题,请大家帮助?
- 这里谁的记忆力最好?
- 请问,DELPHI如何调用3DMAX的建筑模型或者通信
- 哪里有delphi6.0下mssqlserver2000 for dbexpress 的驱动?
void __fastcall TMainFrm::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
//这儿你根据条件设定颜色,
if ((ACol%2==1) && ARow!=0) {
StringGrid1->Canvas->Brush->Color = clWhite;
StringGrid1->Canvas->FillRect(Rect); //用上面设定的颜色填充
} StringGrid1->Canvas->TextRect(Rect, Rect.Left+2,
Rect.Top+2, StringGrid1->Cells[ACol][ARow]);}
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if 条件1 then
begin
DBGrid1.Canvas.Brush.Color:=clYellow; //背景色为黄色
DBGrid1.Canvas.Font.Color := clRed;
end
else
if 条件2 then
begin
DBGrid1.Canvas.Brush.Color:=clSkyBlue; //背景色为天蓝色
DBGrid1.Canvas.Font.Color := clPurple;
end
else
DBGrid1.Canvas.Font.Color:=clGreen;//默认的
DBGrid1.DefaultDrawColumnCell(rect,datacol,column,state);//这句一定要加上
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1 do
with Canvas do
begin
if (ARow=Row)and(ACol>=FixedCols) then
Brush.Color:=clRed
else
if (ARow>=FixedRows)and(ACol>=FixedCols) then Brush.Color:=clWhite;
FillRect(Rect);
end;end;end.