StringGride 中,
我想给指定的例加颜色,应该怎么做啊,
比如说,第三例.为绿色.
我想给指定的例加颜色,应该怎么做啊,
比如说,第三例.为绿色.
解决方案 »
- delphi窗体 问题
- 在DELPHI插入记录问题
- 如何在DBgrid中获得选中的cell单元的横坐标和纵坐标?
- TcpClient 关于如何使用~~~~~?--------------------基础问题 高分
- 在delphi中删除文件夹
- 记得有个编写Win32服务的控件,忘了叫什么了。
- 小弟过段时间想去浙江-湖州找工作,想问那里用Delphi的多吗?不多的话,那里用什么多一些呢?
- 文件的操作
- 用websnap做的cgi程序发布到没装delphi的机器上时,出现错误,大家帮忙看一看如何解决,谢谢。
- DLL中的子窗体问题???分不够的话可以再加
- 兄弟们好
- CodeGear™ Delphi® 2007 for Win32 帮助文件 ?
好像onDraw事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); //将第三列背景变为美元绿。
begin
if not((acol=2) //这里决定列序号
and (arow>=stringgrid1.fixedrows)) then
exit; with stringgrid1 do
begin
canvas.Brush.color:=clmoneygreen;//这里决定颜色
canvas.FillRect(Rect);
canvas.TextOut(rect.left+2,rect.top+2,cells[acol,arow])
end;
end;
我曾经设想把列序号赋一个变量,然后由弹出菜单来传递它,增强互动功能。楼主是否可以一试?若实验成功,说一下,让大家共享。
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
//SetGridColor(ARow,ACol,clWhite,$00E1FFFF,Rect,StrGrid);
with StrGrid do
begin
if ACol = 2 then
begin
Canvas.Font.Color := clred; //字体颜色为红的
Canvas.Brush.color:=clMoneyGreen; //背景为 美元绿色
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2,Rect.Top+2,StrGrid.Cells[ACol,ARow]);
end;
end;
end;