DateExpress

Hi All,

I am trying to pupulate a combo box..emm best I give an example..

Table1

ItemID

ItemName

SaleID

Table2

SaleTypeID

Description

My default dataset looks up table 1....like this...

SELECT Table1.ItemID, Table1.ItemName, Table1.SaleID

FROM Table1;

this isnt much use since the sale ID is just a number I want it to lookup table2.Description....so..

SELECT Table1.ItemID, Table1.ItemName, Table2.Description

FROM Table1, Table2

WHERE Table1.SaleID like Table2.SaleTypeID;

This will work (ignore any silly sql errors)...but I would prefer the combo box to have all the descriptions from Table2, thus allowing the user to select a meanfull description......but

if I do this how do I update the database.....ie

if a user changes the sale offer, I cannot send the description back but must send the ID back.

cheers

Baz

[958 byte] By [Bazza99a] at [2007-10-2 6:03:42]
# 1

If you create the ComboBox after you retrieve the information, you can create a new combobox with the data as an array.

box = new JComboBox(data)

Or you could just use DefaultComboBoxModel.

I am not sure what you are talkiing about "user changes sale offer"

You can implement ItemListener to listen for changes to your combobox and handle accordingly.

public void itemStateChanged(ItemEvent evt) {

myComboBox.getSelectedItem

update()

}

I think I understand your problem. You have store a mapping of your ID to your description somewhere, perhaps a vector or array (your design choice), and then retreive the id that way.

If it is one to one -

IDList[index] = your ID and

DescriptionList[index] = your description

jwstudenta at 2007-7-16 13:04:08 > top of Java-index,Desktop,Core GUI APIs...
# 2
Try storing an Object in the combo box: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731
camickra at 2007-7-16 13:04:08 > top of Java-index,Desktop,Core GUI APIs...