stringgrid表格。。第1列为数量,2列为单价,3列为总金额当修改第1列和第2列时候,3列的值自动重新计算。并且2列修改时候,自动将表格中2列所有值汇总的总数赋值 eidt1中。上述事件如何触发?  

解决方案 »

  1.   


    procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    var
        i:integer;
        value:real;
    begin
        if (ACol=0) or (ACol=1) then
            StringGrid1.Cells[2,ARow]:=Format('%.2f',[StrToFloat(StringGrid1.Cells[0,ARow]:=)*StrToFloat(StringGrid1.Cells[1,ARow])]);    value:=0;
        if (ACol=2) then
        begin
            for i:=0 to StringGrid.RowCount-1 do
                value:=value+StrToFloat(StringGrid1.Cells[1,ARow]);
            Edit1.Text:=Format('%.2f',[value]);
        end;        
    end;