Link to home
Start Free TrialLog in
Avatar of jmiqueli
jmiqueli

asked on

TDBGrid question

I'm using a TDBGrid in one of my dialogs.  I've set the DataSource and modified the columns in the Column Editor.  My problem is that there is one column that is not part of the database.  I need to dynamically modify the column myself. In other words, I've added a column in the Column Editor and left FieldName blank.  Is there anyway I can get access to the column in the TDBGrid and add the data I need?

Thanks,
Juan C. Miqueli
juan.miqueli@turner.com
Avatar of pscadden
pscadden

Double-click the dataset component associated with the
datasource to bring up the Fields editor. Go to New and
create a calculated field. This field with the name you give it will
now appear in the TDbgrid. You can use the event for
calculated field to get the information. OR - you can simply
make leave that blank (which I think is what you want) and
the user can enter the field and enter value appropriate
to the other details of the field.
Avatar of jmiqueli

ASKER

I added the new field and made it a calculated field.  The name came up in the Column Editor.  My only question is, where is the event for calculated fields?  Is it the OnGetData?

Juan
The event for calculated fields will be in the Event list for your actual TQuery or TTable dataset component.  Click on the dataset component,  go to its event list, and you will see "OnCalcFields", within which you can set the value of the field.  For example, a field named FIELDNAME in a query component named MyQuery can be set like this:

MyQueryFIELDNAME.Value := ...


Dale

On the dataset component associated with the datasource, after I entered the new field and made it a Calc field. I went to the event on that field. In the OnGetText of the field there is var parameter passed in called Text. I set the Text field to whatever I needed and that worked. I'm going to try your example.

Thanks for your help,
Juan
Be careful with the OnCalcFields event.  It will fire plenty of times.  Make sure that it is a short procedure
ASKER CERTIFIED SOLUTION
Avatar of jameshui
jameshui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial