Displaying Field Component Values in Standard Controls

From RAD Studio
Jump to: navigation, search

Go Up to Displaying, Converting, and Accessing Field Values

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 Vcl.StdCtrls.TEdit control because the value of the CustomersCompany field may have changed:

procedure TForm1.CustomersDataChange(Sender: TObject, Field: TField);
  Edit3.Text := CustomersCompany.Value;
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