下面的演示是每一行的合计数写到本行的最后一个单元格。(输入后敲2次回车表示确认)procedure TFormDemo.StringGridGetEditText(Sender: TObject; ACol, ARow: Integer; var Value: String); begin with StringGrid do begin try StrToFloat(Value); Cells[Pred(ColCount), ARow] := FloatToStr(StrToFloat(Cells[Pred(ColCount), ARow])+StrToFloat(Value)); except end; end; end;procedure TFormDemo.FormCreate(Sender: TObject); var iRow: Integer; begin with StringGrid do begin for iRow := FixedRows to Pred(RowCount) do Cells[Pred(ColCount), iRow] := '0'; end; end;
Rect: TRect; State: TGridDrawState);//会闪烁的,呵呵
begin
With StringGrid1 do
Cells[3,ARow] := Cells[1,ARow] + Cells[2,ARow] ;
end;
====
冯叔叔年纪大了,没有你们那么好的瞌睡啊。 刚才去外面巡视去了。呵呵lihuasoft(学习低调做人)又在乱解答题目了。抓住OnDrawCell不分青红皂白的一通胡用。呵呵呵呵。 华哥哥不要又生气哈。
ARow: Integer; var Value: String);
begin
with StringGrid do
begin
try
StrToFloat(Value);
Cells[Pred(ColCount), ARow] := FloatToStr(StrToFloat(Cells[Pred(ColCount), ARow])+StrToFloat(Value));
except
end;
end;
end;procedure TFormDemo.FormCreate(Sender: TObject);
var
iRow: Integer;
begin
with StringGrid do
begin
for iRow := FixedRows to Pred(RowCount) do
Cells[Pred(ColCount), iRow] := '0';
end;
end;