PDA

Ver la Versión Completa : calculo en dbgrid


dariana20
12-06-2006, 21:13:33
Necesito saber como lograr q un campo de un dbgrid me muestre el resultado
de la multilplicacion de otros dos.Estoy trabajando con sql server.
???????:(

delphi.com.ar
12-06-2006, 21:32:43
Puedes hacerlo desde la consulta:
SELECT CAMPO1, CAMPO2, CAMPO1*CAMPO2 PRODUCTO FROM TABLA
O con campos calculados:
To create a calculated field in the New Field dialog box:

1 Enter a name for the calculated field in the Name edit box. Do not enter the name of an existing field.
2 Choose a data type for the field from the Type combo box.
3 Enter the size of the field in the Size edit box, if appropriate. Size is only relevant for fields of type TStringField, TBytesField, and TVarBytesField.

4 Select Calculated or InternalCalc in the Field type radio group. InternalCalc is only available if you are working with a client dataset. The significant difference between these types of calculated fields is that the values calculated for an InternalCalc field are stored and retrieved as part of the client dataset's data.
5 Choose OK. The newly defined calculated field is automatically added to the end of the list of persistent fields in the Field editor list box, and the component declaration is automatically added to the form's or data module's type declaration.

6 Place code that calculates values for the field in the OnCalcFields event handler for the dataset. For more information about writing code to calculate field values, see Programming a calculated field.

Saludos!