Board index » delphi » Q: How to edit a calculated field in a DBGrid

Q: How to edit a calculated field in a DBGrid

I have a number which evaluates via the OnCalcluate Event to so some
checkboxes in a DbGrid. I want to do the way back too: Editing the
Checkboxes and storing the calculated number in the table. But as the
calclualted fields are readonly I am stuck.

Any hints availiable?

Thank you!

--
Bernd Maierhofer
dato Denkwerkzeuge
EDV-Projekte, Beratung, Softwareerstellung
Corneliusgasse 4
A-1060 Wien, Austria
Fax:  (43)(1)581 29 80
Mail: Ber...@dato.at

 

Re:Q: How to edit a calculated field in a DBGrid


Write the code to manipulate the calculated field.
Even if calculated fields are readonly, I don't think their associated
controls are (?). Therefore you can use the events to manipulate .the field.

- Erling G

Quote
Bernd Maierhofer wrote in message <6qnavm$2q...@orudios.magnet.at>...
>I have a number which evaluates via the OnCalcluate Event to so some
>checkboxes in a DbGrid. I want to do the way back too: Editing the
>Checkboxes and storing the calculated number in the table. But as the
>calclualted fields are readonly I am stuck.

>Any hints availiable?

>Thank you!

>--
>Bernd Maierhofer
>dato Denkwerkzeuge
>EDV-Projekte, Beratung, Softwareerstellung
>Corneliusgasse 4
>A-1060 Wien, Austria
>Fax:  (43)(1)581 29 80
>Mail: Ber...@dato.at

Re:Q: How to edit a calculated field in a DBGrid


Quote
>Write the code to manipulate the calculated field.
>Even if calculated fields are readonly, I don't think their associated
>controls are (?). Therefore you can use the events to manipulate .the

field.

Nope, the controls do not receive any edit-messages. Thats my problem.

Bernd

Re:Q: How to edit a calculated field in a DBGrid


Calculated fields are not readonly nor are their DB controls.
I think your problem is that the value of the calculated fields just exists
when the OnCalcFields event is called (see Delphi Help: Using OnCalcFields).
To keep the value or edit it, you have to use a var or a control that is not
DB aware.

Every time you change your calculated field, you trigger the OnCalcFields
event which calculate your field and erase your edit.

If you trace through your code and use the De{*word*81}, you will see that the
calculated field just keep the values until the OnCalcFields event is called
(and that is frequently).

Be careful - if you modify the dataset in OnCalcFields, this may lead to
recursion and a stack overflow.

Quote
Bernd Maierhofer wrote in message <6qrl5u$l4...@orudios.magnet.at>...
>>Write the code to manipulate the calculated field.
>>Even if calculated fields are readonly, I don't think their associated
>>controls are (?). Therefore you can use the events to manipulate .the
>field.

>Nope, the controls do not receive any edit-messages. Thats my problem.

>Bernd

Re:Q: How to edit a calculated field in a DBGrid


Quote
Bernd Maierhofer wrote:

> I have a number which evaluates via the OnCalcluate Event to so some
> checkboxes in a DbGrid. I want to do the way back too: Editing the
> Checkboxes and storing the calculated number in the table. But as the
> calclualted fields are readonly I am stuck.

> Any hints availiable?

> Thank you!

> --
> Bernd Maierhofer
> dato Denkwerkzeuge
> EDV-Projekte, Beratung, Softwareerstellung
> Corneliusgasse 4
> A-1060 Wien, Austria
> Fax:  (43)(1)581 29 80
> Mail: Ber...@dato.at

If you are using sql you can make a dummy/calculated field in you sql,
this field is not read only.

--
J?rgen Aase
Oslo
Norway
ja...@c2i.net

Re:Q: How to edit a calculated field in a DBGrid


Yeah, this works ok. Altough it is somewhat clumsy to have dummy fields in
the SQL.
Thank you for your input!
Bernd.
Quote
>If you are using sql you can make a dummy/calculated field in you sql,
>this field is not read only.

>--
>J?rgen Aase
>Oslo
>Norway
>ja...@c2i.net

Other Threads