Discussion:
Control to use advice
(too old to reply)
Ian
2011-10-04 16:46:12 UTC
Permalink
Hi all

I can't believe I'm asking such a dumb question, but here goes.

I need to supply a data-entry form on a Products table. The user needs
a combo on the Product Name field so they can, if required, select an
existing product name (and change other field values to create a new
record) or they can type a new name directly into the box. The last
time I did anything like this was about ten years ago and ISTR using a
Woll2Woll component. But as I haven't done anything like this in
years, I'm at a loss as to what to use now. I've got the DevExpress
stuff but an hour messing around hasn't helped very much.

Any advice will be very gratefully received.

Cheers

Ian
Maarten Wiltink
2011-10-04 20:51:38 UTC
Permalink
Post by Ian
I need to supply a data-entry form on a Products table. The user needs
a combo on the Product Name field so they can, if required, select an
existing product name (and change other field values to create a new
record) or they can type a new name directly into the box. The last
time I did anything like this was about ten years ago and ISTR using a
Woll2Woll component. But as I haven't done anything like this in
years, I'm at a loss as to what to use now. I've got the DevExpress
stuff but an hour messing around hasn't helped very much.
This is a fairly standard use case for a combobox but I've never seen
really good support for it. Then again, I haven't seen many component
sets at all.

Using a standard VCL TComboBox, you could set the style to dropdown,
not dropdownlist, to allow both selecting and typing. There are events
you could handle to see if the text matches any existing item and do all
the work for adding it if it doesn't.

I can imagine that one of the biggest problems is when exactly to decide
that the current input should be saved as a new record. Do you have a
button somewhere or are you relying on Enters and Exits?

Groetjes,
Maarten Wiltink
Ian
2011-10-05 05:21:33 UTC
Permalink
Post by Maarten Wiltink
This is a fairly standard use case for a combobox but I've never seen
really good support for it. Then again, I haven't seen many component
sets at all.
Using a standard VCL TComboBox, you could set the style to dropdown,
not dropdownlist, to allow both selecting and typing. There are events
you could handle to see if the text matches any existing item and do all
the work for adding it if it doesn't.
I can imagine that one of the biggest problems is when exactly to decide
that the current input should be saved as a new record. Do you have a
button somewhere or are you relying on Enters and Exits?
Hi Maarten

Many thanks for your reply. There's a Save/Cancel option. The form
opens in dsInsert. I'll give the standard DBCombo another go. I had a
play with it yesterday, but it was at the end of a long day and I
suspect that I was missing something in how I set it up.

Thanks again

Ian
Maarten Wiltink
2011-10-05 16:03:48 UTC
Permalink
Post by Maarten Wiltink
Using a standard VCL TComboBox, you could set the style to dropdown,
not dropdownlist, to allow both selecting and typing. There are events
you could handle to see if the text matches any existing item and do
all the work for adding it if it doesn't.
I can imagine that one of the biggest problems is when exactly to
decide that the current input should be saved as a new record. Do
you have a button somewhere or are you relying on Enters and Exits?
[...] There's a Save/Cancel option. The form
opens in dsInsert. I'll give the standard DBCombo another go. I had
a play with it yesterday, but it was at the end of a long day and I
suspect that I was missing something in how I set it up.
Opening the form (the dataset, really) in dsInsert neatly handles the
work for adding the record. What it doesn't handle is updating an
existing record instead if it matches better.

My experience with datasets and data-aware controls is both limited and
traditionally interrupted by bouts of violent retching, but you could
try to break in on the dataset's handling of a record insert (or post).
If the contents for the new record match an existing record, there are
probably events to catch to abort the insertion and switch to a different
record, then update that, instead.

These events might be on the dataset or on the datasource. They will not
be on the combobox.

Groetjes,
Maarten Wiltink

Loading...