[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

DBGrid and adding Fields

Every expert,

How can I add a column (eg. FullName) to the DBGrid that is combine of other fields (eg. FirstName + LastName) in the same DBGrid ??????

By the way, how can I link a DBEdit to a field (eg. FullName) that is combin of other fields (eg. FirstName + LastName) in the Table without adding a field to the Table ??????

Andrew
0
andrewyu
Asked:
andrewyu
1 Solution
 
itamarCommented:
I'll try a step-by-step answer:

1. Double click your TTable or TQuery component;

2. Right click the fields editor area;

3. Choose 'New Field...' option;

4. Type a name for the new field, e.g. "FullName";

5. Choose String for the Type;

6. Check the "Calculated" option for 'Field type';

7. Click OK;

8. Put the following code in the "OnCalcFields" event handler of TQuery or TTable component:
 begin
   FullName.AsString := FirstName.AsString + ' ' + LastName;
 end

9. Now, when you go to the Columns property editor of the DBGrid component, the new field must be available.

10. ADD IT !!

The principle is the same to link the DBEdit. Follow the steps 1 to 8 and then choose the new field (FullName) in the DataField property of DBEdit.

I Hope this can helps.

------S.M.I. (Sory mi inglige ;) -------------
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now