In a TTable I have a byte field which I will set according to the user's
selection of a DBComboBox. I have a stringlist which I copy to the
DBComboBox' Items at FormShow. But I can't get the DBCombo to save the
selected ItemIndex, it tries to assign the text instead.
How can I get it to assign its index value to its TField and not the Item
TEXT?? (Or do I have to do this manually...?)
Thanks for any comment on this...
Regards
Tor
a TDBComboBox _ALWAYS_ will always write the text-value in the table
-that's what it is for.
You have to do it manually and therefor I recommend that you change your
TDBComboBox to a TComboBox.
When posting your records add:
TTable.FieldByName('<MYFIELD>').AsInteger := ComboBox.ItemIndex;
this is just one extra-line (and one when for showing the record).
Luc.
Tor Tveitane schrieb:
On Sat, 03 Oct 1998 00:22:41 +0100, Lucas Franzen <l...@rol3.com>
wrote:
>Hi Tor,
>
>a TDBComboBox _ALWAYS_ will always write the text-value in the table
>-that's what it is for.
>You have to do it manually and therefor I recommend that you change your
>TDBComboBox to a TComboBox.
>When posting your records add:
>TTable.FieldByName('<MYFIELD>').AsInteger := ComboBox.ItemIndex;
>
>this is just one extra-line (and one when for showing the record).
>
>Luc.
>
Dennis Powers
PC/POLL SYSTEMS
V 319-556-2323
F 319-556-0835
Den...@pcpoll.com
Maybe, but I think that this will be more than one line and a new
procedure anyway.
DBbound controls are made for representing the values of the underlying
table / fields. If you're going to misuse them I think you have to live
with the fact that this will lead to extra code.
Luc.
>Dennis Powers schrieb:
I'm trying to understand the consequences of using a tComboBox as
opposed to a tdbComboBox. The tdbComboBox allows me to specify a data
source and field whereas the value for a tComboBox must be explicitly
set and also explicitly posted back to the table, correct? Doesn't
this imply a line of code in the forms OnActivate event to set the
value in the tComboBox? Also, as you pointed out, we need to set the
table to the value of the tComboBox but we may need to account for
this in more than one place if there are multiple ways to post to the
record. Is my understanding correct?