PDA

View Full Version : Default value in combo box



Nico33
24 Nov 2009, 11:46 PM
Hi all,

I'm trying to put a default value in my combo box, but it's not working.
This is my sample code :


SimpleComboBox<String> scb = new SimpleComboBox<String>();
scb.add("Value1");
scb.add("Value2");
scb.add("Value3");
scb.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>()
{
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se)
{
MessageBox.alert("Selected value", "Selected value : " + se.getSelectedItem().getValue(), null);
}
});
scb.setValueField("Value1");
panel.add(scb);How to correct it ?
Thanks in advance for your answers

sven
25 Nov 2009, 3:59 AM
You are not setting any value. You are setting the name of a value field. You need to use setSimpleValue

Nico33
25 Nov 2009, 4:50 AM
Thanks for your answer, i'll try it ;)