PDA

View Full Version : How to set the value of Combo



Suma
22 Jun 2009, 2:55 AM
Hi,
I have a Combo and a ListStore which is display in Combo. I want to defaultly set the value of Combo by the first data in the ListStore when the Combo is rendered. Kindly help me how to do this.

daddieke
22 Jun 2009, 4:59 AM
On the ComboBox you can use setValue() or one of the related methods. To find the value you want to set, there are different findModel() methods on the ListStore.

In summary :
comboBox.setValue(comboBox.getStore().findModel(...));

If for some reason you want to set the first item as default, you can do something like :
comboBox.setValue(comboBox.getStore().getModels().get(0));