delphi 如何在按钮上添加

procedureTfm_chWasteck.BitBtn2Click(Sender:TObject);beginsumADODS.Close;sumADODS.Comm... procedure Tfm_chWasteck.BitBtn2Click(Sender: TObject);
begin
sumADODS.Close;
sumADODS.CommandText:='select sum(wh2) as 二楼仓库数,sum(wh5) as 五楼仓库数,sum(whsys) as 仓库数,sum(sys2) as 二楼转机纸数,sum(sys5) as 五楼转机纸数,sum([sys2+5]) as 两楼转机纸数,sum(syswh) as 系统总数,sum(differ) as 相差数 from fm_chwasteck';
sumADODS.open;//到这里是查询内容,下面是改变行颜色
if sumADODS.FieldByName('differ').AsCurrency>1 then

DBGrid2.Canvas.Brush.Color:=clWhite;

DBGrid2.DefaultDrawColumnCell(Rect,DataCol, Column, State);
end;

但是运行时提示错误:
[Error] U_chWasteck.pas(228): There is no overloaded version of 'Rect' that can be called with these arguments
[Error] U_chWasteck.pas(228): Undeclared identifier: 'State'
[Fatal Error] ym.dpr(30): Could not compile used unit 'U_chWasteck.pas'
请问如何添加才可以运行啊。
展开
 我来答
快乐居家美食
2012-01-15 · TA获得超过1944个赞
知道大有可为答主
回答量:2392
采纳率:100%
帮助的人:1579万
展开全部
procedure Tfm_chWasteck.BitBtn2Click(Sender: TObject);
begin
sumADODS.Close;
sumADODS.CommandText:='select sum(wh2) as 二楼仓库数,sum(wh5) as 五楼仓库数,sum(whsys) as 仓库数,sum(sys2) as 二楼转机纸数,sum(sys5) as 五楼转机纸数,sum([sys2+5]) as 两楼转机纸数,sum(syswh) as 系统总数,sum(differ) as 相差数 from fm_chwasteck';
sumADODS.open;//到这里是查询内容,下面是改变行颜色
//---------------------------------------------------------------------------------//
//这部分放在dbgrid的DrawColumnCell事件里面
if sumADODS.FieldByName('differ').AsCurrency>1 then
DBGrid2.Canvas.Brush.Color:=clWhite;
DBGrid2.DefaultDrawColumnCell(Rect,DataCol, Column, State);
//--------------------------------------------------------------------------------//
end;

可以参考隔行显示不同颜色背景的代码,你只需要更改其中的条件和背景颜色就可以了。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (IBTable1.RecNo mod 2) = 0 then
(Sender as TDBGrid).Canvas.Brush.Color := clGray //定义背景颜色:灰
else
(Sender as TDBGrid).Canvas.Brush.Color := clWhite; //定义背景颜色:白

(Sender as TDBGrid).DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
影音最终幻想2023
2012-01-15
知道答主
回答量:27
采纳率:0%
帮助的人:11.9万
展开全部
[Error] U_chWasteck.pas(228): There is no overloaded version of 'Rect' that can be called with these arguments
228行没有有效重载函数

[Error] U_chWasteck.pas(228): Undeclared identifier: 'State'
'State' 未声明
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式