Ver Mensaje Individual
  #6  
Antiguo 07-11-2008
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 24
maeyanes Va por buen camino
Hola...

Tienes de dos, sumar los valores al momento de irlos asignando al grid:

Código Delphi [-]
var
  ResultadoTotal: Integer;

begin
  // Inicializamos a cero antes de agregar las filas al StringGrid
  ResultadoTotal :=  0;
  // Aquí se asignan los valores a las 3 filas que quieres sumar:
  ResultadoTotal := ResultadoTotal + ValorAgregado1;
  ResultadoTotal := ResultadoTotal + ValorAgregado2;
  ResultadoTotal := ResultadoTotal + ValorAgregado3;
end;

O también puedes usar las 3 filas anteriores al resultado para sumarlas:

Código Delphi [-]
var
  ResultadoTotal: Integer;
  I: Integer;

begin
  ResultadoTotal := 0;
  for I := sgGrafica.RowCount - 3 to Pred(sgGrafica.RowCount) do
    ResultadoTotal := ResultadoTotal + StrToInt(sgGrafica.Cells[1, I]);
  sgGrafica.RowCount := sgGrafica.RowCount + 1;
  sgGrafica.Cells[0, Pred(sgGrafica.RowCount)] := 'Resultado Total';
  sgGrafica.Cells[1, Pred(sgGrafica.RowCount)] := ResultadoTotal
end;


Saludos...
Responder Con Cita