Question

Inside an SWT Table I have many TableItems. I want to move one of them from index X to index Y. Is there a way to do that? How?

Thanks.

Was it helpful?

Solution

I don't think there is a direct method to do this. But as a workaround, try the below method. I have used something similar once.

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

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top