views:

2336

answers:

2

I create a Combo-box control in org.eclipse.swt.widgets.Table The code snippet is below

            ...
 TableEditor editor = new TableEditor (table_LLSimDataFileInfo);
 CCombo combo = new CCombo (table_LLSimDataFileInfo, SWT.NONE);
 combo.setText("CCombo");
 combo.add("item 1");
 combo.add("item 2");
 editor.grabHorizontal = true;
        editor.setEditor(combo, items[i], 0);
            ...

How can I dynamically change the combo-box list for a selected row in the table (For e.g. item1, item2 etc changed to item4, item5, item7 etc for row 5 only) by triggering of some event. The event in my case is selection in another combo-box whose list does not change

A: 

The TableEditor docs show a simple example with a selection listener that identifies the current selected row.

You just need to customize this example and dynamically fill the Combo acording to the selected row.

bruno conde
+1  A: 

You should set a SelectionListener on your other CCombo, in order to call an update on your second CCombo.

This WavAudioSettingComposite class is a good example.

Something like:

public class ValueChanged implements SelectionListener{

    public void widgetDefaultSelected(SelectionEvent e) {
    }

    public void widgetSelected(SelectionEvent e) {
        if(e.getSource()==myForstCCombo){
         // call update on your second CCombo
        }
    }
}

public void updateSecondCCombo(int[] newValues){
    int oldbitrate=getFramerate();
    mySecondCCombo.removeAll();

    for (int i = 0; i < newValues.length; i++) {
        mySecondCCombo.add(""+newValues[i]);
    }
}
VonC
Great! You're welcome.
VonC
If it helped, amarnath, you should accept the answer. Or at least vote it up if you want to wait and see if some other, better idea comes up.I'm voting it up cause it's a good answer, and to get the question out of the "unanswered questions" section.
Sandman
@Sandman: thank you. I never look at that "unanswered" section, so I was not aware of that. I am, however, used to getting no vote or "accept" status on answer for "new user" ;) The voting or "accept" process may not be that obvious at first for the casual user.
VonC