Displaying Data as Labels

From RAD Studio
Jump to: navigation, search

Go Up to Displaying a Single Record

TDBText is a read-only control similar to the TLabel component on the Standard category of the Tool palette. A TDBText control is useful when you want to provide display-only data on a form that allows user input in other controls. For example, suppose a form is created around the fields in a customer list table, and that once the user enters a street address, city, and state or province information in the form, you use a dynamic lookup to automatically determine the zip code field from a separate table. A TDBText component tied to the zip code table could be used to display the zip code field that matches the address entered by the user.

TDBText gets the text it displays from a specified field in the current record of a dataset. Because TDBText gets its text from a dataset, the text it displays is dynamic - the text changes as the user navigates the database table. Therefore you cannot specify the display text of TDBText at design time as you can with TLabel.

Note: When you place a TDBText component on a form, make sure its AutoSize property is True (the default) to ensure that the control resizes itself as necessary to display data of varying widths. If AutoSize is False, and the control is too small, data display is clipped.

See Also