我正在寻找一种方法来显示表格/网格的第一列中的其他三列,其中一个与组合框,其他与复选框。我一直在尝试使用TreeViewer进行这项工作,但它不太适合我在寻找的东西。树合在一起很好。在Combobox列中,我使用了列的EditorSupport并在getCellEditor方法中返回一个ComboboxCellEditor,但只能在列中选择一个单元格时才能看到列中有组合框。然后,当您单击单元格时,所选值将返回到默认空白。复选框列的相同情况仅在选中单元格时才可见。我正在寻找能够显示我的树的组合框,并且复选框列始终可见。我已经看过TableViewer,但是无法在第一列的树中找到强制的方法。我看过Nebula Grid,但看起来不像它支持组合框。有关如何让其中一个工作的任何提示,比如我正在寻找的东西,或者我应该看到的其他树/表格/网格。谢谢。SWT TreeViewer与组合框和复选框
编辑:这是EditingSupport类的代码。
private class ComboBoxEditingSupport extends EditingSupport
{
private ComboBoxCellEditor cellEditor;
public ComboBoxEditingSupport(ColumnViewer viewer)
{
super(viewer);
cellEditor =
new ComboBoxCellEditor(((TreeViewer) viewer).getTree(),
new String[] {
"Some String",
"Some other String" }, SWT.READ_ONLY);
}
@Override
protected CellEditor getCellEditor(Object element)
{
if (element instanceof MyObject
{
return cellEditor;
}
return null;
}
@Override
protected boolean canEdit(Object element)
{
if (element instanceof MyObject
{
return true;
}
return false;
}
@Override
protected Object getValue(Object element)
{
return 0;
}
@Override
protected void setValue(Object element, Object value)
{
TreeItem[] ti = treeViewer.getTree().getSelection();
CCombo combo = ((CCombo) cellEditor.getControl());
String str = combo.getItem(combo.getSelectionIndex());
ti[0].setText(1, str);
}
}
我已经厌倦swt TreeViewer TreeColumnViewers的列。我尝试了Nebula Grid。这是关闭的,但它不支持在它的外观列中的组合框。我试过TableViewer,但不支持我需要的树。 – EdDen
编辑支持与ComboboxCellEditor应该工作,这听起来像你在'setValue'方法有问题 - 向我们展示你的代码。 –