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

DBCombobox.ItemIndex....

1,240 views
Skip to first unread message

Tor Tveitane

unread,
Oct 2, 1998, 3:00:00 AM10/2/98
to
Hi,

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

Lucas Franzen

unread,
Oct 3, 1998, 3:00:00 AM10/3/98
to
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.

Tor Tveitane schrieb:

Dennis Powers

unread,
Oct 3, 1998, 3:00:00 AM10/3/98
to
If the tTable has persistant fields could'nt he add a OnGetText and
OnSetText event handeler to make the translation?


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

Lucas Franzen

unread,
Oct 3, 1998, 3:00:00 AM10/3/98
to
Dennis Powers schrieb:

>
> If the tTable has persistant fields could'nt he add a OnGetText and
> OnSetText event handeler to make the translation?
>

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

unread,
Oct 3, 1998, 3:00:00 AM10/3/98
to
On Sat, 03 Oct 1998 10:54:51 +0100, Lucas Franzen <l...@rol3.com>
wrote:

>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?

0 new messages