【发布时间】:2009-07-29 20:40:59
【问题描述】:
在 SWT 表中,我有许多 TableItem。 我想将其中一个从索引 X 移动到索引 Y。 有没有办法做到这一点?怎么样?
谢谢。
【问题讨论】:
在 SWT 表中,我有许多 TableItem。 我想将其中一个从索引 X 移动到索引 Y。 有没有办法做到这一点?怎么样?
谢谢。
【问题讨论】:
我认为没有直接的方法可以做到这一点。但作为一种解决方法,请尝试以下方法。我曾经使用过类似的东西。
public void moveTableItem(Table table, int from, int to) {
TableItem item2Move = table.getItem(from);
TableItem newTableItem = new TableItem(table, SWT.NONE, to);
newTableItem.setText(item2Move.getText());
// You may want to clone the entire item here; and not just the text.
// Dispose off, the old item.
item2Move.dispose();
}
【讨论】: