RAD Studio |  |

Displaying Field Component Values in Standard Controls
See Also
Collapse All

An application can access the value of a dataset column through the Value property of a field component. For example, the following OnDataChange event handler updates the text in a TEdit control because the value of the CustomersCompany field may have changed:

Copy Code

    procedure TForm1.CustomersDataChange(Sender: TObject, Field: TField);
    begin
      Edit3.Text := CustomersCompany.Value;
    end;

Copy Code

    void __fastcall TForm1::Table1DataChange(TObject *Sender, TField *Field)
    {
      Edit3->Text = CustomersCompany->Value;
    }

This method works well for string values, but may require additional programming to handle conversions for other data types. Fortunately, field components have built-in properties for handling conversions.

Note: You can also use Variants to access and set field values.
See Also

Accessing Field Values with a Dataset's Fields Property

Accessing Field Values with a Dataset's FieldByName Method

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!