Beginner's questions regarding Delphi
>Could somebody answer my beginner's questions.....Please!
>1)In DBGrid, how can I display one field from a different table?
Fields from more than one table can appear automatically in the same
TDBGrid only when the data set for that TDBGrid is a TQuery that links,
through SQL, those multiple tables together. When you do this, all of the
fields in the SELECT query -- whether from only one or from all tables so
linked -- appear in the TDBGrid.
It is possible, though, to take special actions above and beyond the
automatic process described above to have fields from other tables appear
in a TDBGrid when the data set for that TDBGrid is based on only one table
(as with a TTable). One way to do this would be to set up calculated fields
and in the OnCalcFields event procedure for that TTable perform some
actions that put field values from the other table into the calculated
field. One example of such an action could be a look-up from the other
table based on a field value in the current record of the main table for
the TDBGrid. Calculated fields, though, will be read-only.
>2)How do I display multiple fields in TDBCombobox? It only displays one
The Items property of the TDBComboBox component must be filled manually.
The values placed in each element of the Items property array of String
values can be a field from a table, some programmatically drived value,
literals created in the application, or a concatenation of multiple fields
from a table. There is no limitation in this component to displaying only a
single field value.
On the other hand, the list of values for a TDBLookupCombo does have some
limitations on what can be displayed. This component does not have an Items
property, and instead gets the values for the list directly from a table.
(Specifically, from a TTable component connected to a table and through a
TDataSource component.) The DataSource property designates the data source
from which any displayed values will come. The LookupField property
indicates the field in the source data set that will supply the value for
the TDBLookupCombo. This property is limited to only a single field because
it is that single field that would be inserted into a target data set,
designated through the DataSource and DataField properties. The
LookupDisplay property allows you to designate what field value or field
values will be displayed in the list. This property can be set so the
component displays only one or multiple fields from the source data set.
The values displayed in the TDBLookupCombo component's list will be
affected by the settings of the LookupField and LookupDisplay properties
taken as a set. The LookupField must always be set for the component to
display any field values at all. If the LookupField property is set to a
field in the source data set and LookupDisplay is left blank, only the
value for the field designated in LookupField will be displayed in the
list. If the LookupField property is set to a field in the source data set
and LookupDisplay is set to one or more fields, the field value or field
values set in LookupDisplay are what are displayed in the list. Regardless
of the setting of LookupDisplay, the field pointed to in LookupField is
always the value inserted into the targer data set and field (DataSource
and DataField properties), if these are designated at all.
When multiple fields are displayed in the TDBLookupCombo selection list,
the field are listed in order of desired appearance in the LookupDisplay
property, each separated by a semi-colon, as in:
LookupDisplay := 'LASTNAME;FIRSTNAME;CITY';
>3)I have picture set in Paradox and it works fine, but when I create a
The picture constraints you can define in the Database Desktop utility
(DBD) or Paradox itself for Paradox tables are not recognized or supported
by Delphi. If you want to apply a picture template to a field in a Delphi
application, you would either need to 1) use the TField component's
EditMask property or programmatically intercept end-user keystrokes at
run-time and allow or 2) disallow keys depending on the current position
within the field value or other developer-defined criteria.
Steve Koterski "Knowledge advances by steps, and not by
Product Group Manager leaps."
Delphi Technical Support -- Lord Macaulay, 1800-1859
Borland International, Inc.