tags:

views:

280

answers:

1

I have the Comboviewer object for which i am adding a list with two values say Type1 and Type2.

But while displaying it is displaying as : [Type1, Type2] instead of : Type1 then below this Type2.

And i want the first one to be selected by default.

need help. thanks

+1  A: 
class Type
{
    private final String    m_name;

    Type(String name)
    {
        m_name = name;
    }

    public String toString()
    {
        return "Type " + m_name;
    }
}

Type type1 = new Type("1");
Type type2 = new Type("2");
ComboViewer comboViewer = new ComboViewer(combo);
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setInput(new Type[] {type1, type2};
comboViewer.setSelection(new StructureSelection(type1));
Kire Haglin
thanks Kire, But what is this combo here
GK
It's the combo widget that the ComboViewer wraps, but you could call it with the parent composite and ComboViewer will create one for you.
Kire Haglin