Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting default values for a TDBLookupCombobox component

2 views
Skip to first unread message

Soren

unread,
Apr 7, 2003, 4:50:42 PM4/7/03
to
I am writing an application where I have a table with several foreign key
fields. I would like to provide the user with a default value for each
foereign key field as well as a list with valid values. The
TDBLookupComboBox does almost what I want.

But it lack two features - as far as I know:

- The ability to set a default value
- Enable the user to key in the value

I have been looking to find a way make it happen, but with no luck. I have
looked around to find another component that could support my requirements
but haven't found it yet.

Does anybody know how it can be done with TDBLookupCOmbobox or know of a
component that does I would be very gratefull.


brgds,
Soren...


bosVision
Bakketoppen 23
DK-3450 Allerod

email: sbl...@post7.tele.dk


Peter Below (TeamB)

unread,
Apr 8, 2003, 6:36:07 AM4/8/03
to
In article <3e91e4ab$1...@newsgroups.borland.com>, Soren wrote:
> I am writing an application where I have a table with several foreign key
> fields. I would like to provide the user with a default value for each
> foereign key field as well as a list with valid values. The
> TDBLookupComboBox does almost what I want.
>
> But it lack two features - as far as I know:
>
> - The ability to set a default value

You are looking for that in the wrong place. To set defaults you override
the OnNewRecord event of the dataset and there assign the default values to
the record fields. This will be automatically reflected in the associated
data-aware controls. This is a general rule: in code you never modify the
data-aware controls, you modify the fields of the associated dataset.

> - Enable the user to key in the value

The TDBLookupCombobox allows the user to select from the available values,
which is much preferrable (=less error prone) than allowing the value to be
typed in. If the user needs a means to add new values to the lookup dataset,
consider placing an "Add" button for that next to the lookup combobox. The
button would pop up an input dialog for the new value. If new values are
added infrequently that is a pretty good solution. If new values are added
frequently it may be a bit cumbersome, though. But it makes the users intent
clear. If you allow typing in a value both for selecting an existing and
adding new values to the lookup dataset you cannot really distinguish a
genuine new value from a simple typo made when the user intended to select
an existing value.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


0 new messages