Bueno yo mismo me respondo
recuerdan mi código :
Código Delphi
[-]procedure TFrmAgregarItems.SBAgregarClick(Sender: TObject);
var i : integer;
SubTotal : double;
begin
FrmVentas.SGListaProductos.Cells[1,FrmVentas.SGListaProductos.RowCount-1] := ECantidad.Text;
FrmVentas.SGListaProductos.Cells[2,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidad.Caption;
FrmVentas.SGListaProductos.Cells[3,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigo.Caption;
FrmVentas.SGListaProductos.Cells[4,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigoBarra.Caption;
FrmVentas.SGListaProductos.Cells[5,FrmVentas.SGListaProductos.RowCount-1] := DBTDescripcion.Caption;
FrmVentas.SGListaProductos.Cells[6,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidadPrecio.Caption;
FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;
FrmVentas.SGListaProductos.RowCount := FrmVentas.SGListaProductos.RowCount+1;
SubTotal := 0;
For i:=1 to FrmVentas.SGListaProductos.RowCount-1 do
SubTotal := SubTotal + StrToFloat(FrmVentas.SGListaProductos.Cells[8,i]);
FrmVentas.LSubTotal.Caption := FormatFloat('%8.2n',SubTotal);
Close;
end;
y me salía ese puñetero error ??
Pues ahora está así y no me sale ese error
Código Delphi
[-]procedure TFrmAgregarItems.SBAgregarClick(Sender: TObject);
var i : integer;
SubTotal : double;
begin
FrmVentas.SGListaProductos.Cells[1,FrmVentas.SGListaProductos.RowCount-1] := ECantidad.Text;
FrmVentas.SGListaProductos.Cells[2,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidad.Caption;
FrmVentas.SGListaProductos.Cells[3,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigo.Caption;
FrmVentas.SGListaProductos.Cells[4,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigoBarra.Caption;
FrmVentas.SGListaProductos.Cells[5,FrmVentas.SGListaProductos.RowCount-1] := DBTDescripcion.Caption;
FrmVentas.SGListaProductos.Cells[6,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidadPrecio.Caption;
FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;
SubTotal := 0;
For i:=1 to FrmVentas.SGListaProductos.RowCount-1 do
SubTotal := SubTotal + StrToFloat(FrmVentas.SGListaProductos.Cells[7,i]);
FrmVentas.SGSubTotal.Cells[1,0] := Format('%8.2n',[SubTotal]);
Close;
end;
ya ahora decidí mostrar el resultado en un StringGrid pequeñito
Pero ese no es el problema por que podría haberlo mostrado en el mismo Label que tenía
Ya ahora esta línea :
la comenté
y puedo agregar ahora los Items al StringGrid que contiene los Items sin problema y me da el resultado del precio1 que lo saco con :
Código Delphi
[-]FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;
y ya todo bién peroooooo!!! ahora un problema.. como es de suponerse esa línea que comenté lo que hace es cada vés que pasa por ahí aumenta 1 al StringGrid y ahora no aumenta nada
y pues si agrego otro Item me sobreescribe al que tengo en el StringGrid pero vamos.. eso es lógico por que no hay que aumente a +1 el StringGrid ahora la pregunta.
Por que esa línea me da problemas con el error que tengo en el anterior mensaje ????
Que otra forma tengo de sumar columnas en un StringGrid ??
saludos