Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TCombobox
Wed, Oct 16 2013 10:29 PMPermanent Link

Eivind

I'm just wondering what is the best way of using a TCombobox while waiting for the Lookup Combobox. I see that the TCombobox can be bound to a dataset field, but I'm not sure how to use it.

My database contains only codes or id's to data in another table in certain fields. I mean, that is the only way to design a good databases.

Lets say we have TABLE_A. Table A have some normal text and integer fields and a field called SEVERITY_ID. The next table is called SEVERITY. It has the SEVERITY_ID field and a SEVERITY_NAME field. It is linked to TABLE_A on the SEVERITY_ID field.

In my app I want the user to choose from the TCombobox the values from table SEVERITY, but only SEVERITY_ID should be stored in TABLE_A. As I understand, I cannot bind the TCombobox to a dataset field, because then only the ID will be displayed. I'm aware that I can manually populate the TCombobox, but the ID's are not consistent. Lets say they are 1,2,7,12 and 55. Where can I store that value? ItemIndex is an property that is automatically populated every time I call Add() and start on 0 right? Also, when the user browse the dataset, I want the TCombobox to show the SEVERITY_NAME and change it as the user continue to browse.

I'm a little lost here. a TLookupCombobox would solve and take care of all this. Do I have to pop up another form with a Grid to display the choices and have a joined text field showing the text values during browsing?

I'm sure that there are several of you out there that have done this before as this is a pretty common practice to store only ID's of the other table in the database.

Thanks for any help

Eivind
Thu, Oct 17 2013 6:54 AMPermanent Link

Eivind

Hmmm, not sure why my post shows up two times





Eivind wrote:

I'm just wondering what is the best way of using a TCombobox while waiting for the Lookup Combobox. I see that the TCombobox can be bound to a dataset field, but I'm not sure how to use it.

My database contains only codes or id's to data in another table in certain fields. I mean, that is the only way to design a good databases.

Lets say we have TABLE_A. Table A have some normal text and integer fields and a field called SEVERITY_ID. The next table is called SEVERITY. It has the SEVERITY_ID field and a SEVERITY_NAME field. It is linked to TABLE_A on the SEVERITY_ID field.

In my app I want the user to choose from the TCombobox the values from table SEVERITY, but only SEVERITY_ID should be stored in TABLE_A. As I understand, I cannot bind the TCombobox to a dataset field, because then only the ID will be displayed. I'm aware that I can manually populate the TCombobox, but the ID's are not consistent. Lets say they are 1,2,7,12 and 55. Where can I store that value? ItemIndex is an property that is automatically populated every time I call Add() and start on 0 right? Also, when the user browse the dataset, I want the TCombobox to show the SEVERITY_NAME and change it as the user continue to browse.

I'm a little lost here. a TLookupCombobox would solve and take care of all this. Do I have to pop up another form with a Grid to display the choices and have a joined text field showing the text values during browsing?

I'm sure that there are several of you out there that have done this before as this is a pretty common practice to store only ID's of the other table in the database.

Thanks for any help

Eivind
Image