SWT: how to get selected value in Combo which embeded in Table

≡放荡痞女 提交于 2019-12-11 04:30:48

问题


i create a column of comboBoxes like this:

for (int i = 0; i < 5; i++) {
    new TableItem(table_1, SWT.NONE);
}

TableItem[] itemsCombo = table_1.getItems();            
for (int i = 0; i < 5; i++) {
    TableEditor editor_1 = new TableEditor(table_1);
    final CCombo comboXX = new CCombo(table_1, SWT.NONE);
    comboXX.setItems(allValues);
    editor_1.grabHorizontal = true;
    comboXX.select(getIndexInLOV(choosenItemList.get(i), allValues));
    editor_1.setEditor (comboXX, itemsCombo[i], 0);
}

Then on clicking "Ok" i want to go through all comboBoxes and collect all values what they store. Still haven't found how it possible to fo. Thanks!


回答1:


I just stumbled across this looking for something else. The way I've done this is with getChildren():

for(Control control : yourComposite.getChildren()) {
    if(control instanceof Combo){
        ((Combo) control).getText());
    }
}


来源:https://stackoverflow.com/questions/17522314/swt-how-to-get-selected-value-in-combo-which-embeded-in-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!