帮忙看一下这段代码 谢谢

土星人在海边 2002-08-21 01:21:03
procedure TForm1.StringGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var checkStr2:String;
begin

if ACol=1 then
begin
if ARow>0 then
begin
checkStr2:=StringGrid2.Cells[1,ARow];
if Length(Trim(checkStr2))=5 then
begin
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.add('select * from goods where tda01c='+''''+checkStr2+'''');
Query3.Open;
if Query3.RecordCount<>0 then
begin
with DBEdit8 do
begin
DBEdit8.DataSource:=DataSource4;
DBEdit8.DataField:='tda03c';
end;
with DBEdit9 do
begin
DBEdit9.DataSource:=DataSource4;
DBEdit9.DataField:='tda08c';
end;
with DBEdit10 do
begin
DBEdit10.DataSource:=DataSource4;
DBEdit10.DataField:='tda092f';
end;
StringGrid2.Cells[2,ARow]:=DBEdit8.Text;
StringGrid2.Cells[3,ARow]:='1';
StringGrid2.Cells[4,ARow]:=DBEdit9.Text;
StringGrid2.Cells[5,ARow]:=DBEdit10.Text;
StringGrid2.Cells[6,ARow]:='10';
StringGrid2.Cells[7,ARow]:=DBEdit10.Text;
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,ARow])*strtofloat(StringGrid2.Cells[7,ARow]));
DBEdit8.Text:='';
DBEdit9.Text:='';
DBEdit10.Text:='';
end;
end;
end;
end;

if ACol=3 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[7,ARow]));
end;
end;
end;

if ACol=6 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[5,ARow])*strtofloat(StringGrid2.Cells[6,ARow])/10);
*************StringGrid2.Cells[7,ARow]:='1000';
end;
end;
end;

if ACol=7 then
begin
if ARow>0 then
begin
if StringGrid2.Cells[2,ARow]<>'' then
begin
StringGrid2.Cells[8,ARow]:=floattostr(strtofloat(StringGrid2.Cells[3,Arow])*strtofloat(StringGrid2.Cells[7,ARow]));
StringGrid2.Cells[6,ARow]:=floattostr(strtofloat(StringGrid2.Cells[7,Arow])/strtofloat(StringGrid2.Cells[5,Arow])*10);
end;
end;
end;
end;

简单的cells编辑 但加上有很多*的那句以后就会不停的执行SQL语句...
郁闷好几天了....
不知道为什么 只要对cells[7,Arow]进行赋值就出错 无论放到哪儿都这样
谁能帮帮我 谢谢
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
newyj 2002-08-21
  • 打赏
  • 举报
回复
再ondraw中对 cells赋值重复触发了ondraw事件,递归了



请大家去 http://www.new7wonders.com/c/voting.php 投长城一票

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧