3

我在 org.eclipse.swt.widgets.Table 中创建了一个组合框控件,代码片段如下

...
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);
...

如何通过触发某些事件来动态更改表中选定行的组合框列表(例如,仅第 5 行的 item1、item2 等更改为 item4、item5、item7 等)。在我的情况下,事件是在另一个组合框中的选择,其列表不会改变

4

2 回答 2

2

您应该在您的另一个 CCombo 上设置一个SelectionListener,以便在您的第二个 CCombo 上调用更新。

这个WavAudioSettingComposite类就是一个很好的例子。

就像是:

public class ValueChanged extends SelectionAdapter {

    public void widgetSelected(SelectionEvent e) {
        if(e.getSource()==myFirstCCombo){
            // 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]);
    }
}
于 2009-03-09T13:29:49.017 回答
0

TableEditor文档显示了一个简单的示例,其中包含一个标识当前选定行的选择侦听器。

您只需要自定义此示例并根据所选行动态填充。Combo

于 2009-03-09T13:24:05.257 回答