在Tstringgrid的onkeypress事件实现的例子: if key=#13 then begin if (yzcol=9) and (stringgrid1.Cells[9,yzrow]<>'') and (stringgrid1.Cells[10,yzrow]<>'') then begin stringgrid1.Cells[11,yzrow]:=format('%.2f',[strtofloat(floattostr(strtofloat(stringgrid1.Cells[9,yzrow])*strtoint(stringgrid1.Cells[10,yzrow])))]); edit5.Text:=format('%.2f',[(strtofloat(edit5.Text)+strtofloat(stringgrid1.Cells[11,yzrow]))]); end; if (yzcol=10) and (stringgrid1.Cells[9,yzrow]<>'') and (stringgrid1.Cells[10,yzrow]<>'') then begin stringgrid1.Cells[11,yzrow]:=format('%.2f',[strtofloat(floattostr(strtofloat(stringgrid1.Cells[9,yzrow])*strtoint(stringgrid1.Cells[10,yzrow])))]); edit5.Text:=format('%.2f',[(strtofloat(edit5.Text)+strtofloat(stringgrid1.Cells[11,yzrow]))]); end;
stringsgrid.cols[i].clear;
if key=#13 then
begin
if (yzcol=9) and (stringgrid1.Cells[9,yzrow]<>'') and (stringgrid1.Cells[10,yzrow]<>'') then
begin
stringgrid1.Cells[11,yzrow]:=format('%.2f',[strtofloat(floattostr(strtofloat(stringgrid1.Cells[9,yzrow])*strtoint(stringgrid1.Cells[10,yzrow])))]);
edit5.Text:=format('%.2f',[(strtofloat(edit5.Text)+strtofloat(stringgrid1.Cells[11,yzrow]))]);
end;
if (yzcol=10) and (stringgrid1.Cells[9,yzrow]<>'') and (stringgrid1.Cells[10,yzrow]<>'') then
begin
stringgrid1.Cells[11,yzrow]:=format('%.2f',[strtofloat(floattostr(strtofloat(stringgrid1.Cells[9,yzrow])*strtoint(stringgrid1.Cells[10,yzrow])))]);
edit5.Text:=format('%.2f',[(strtofloat(edit5.Text)+strtofloat(stringgrid1.Cells[11,yzrow]))]);
end;
如果我修改了它,我不回車那段碼不白寫了嗎?它都不去執行呀
在上面的事件中调用涵数不就行了吗?