tags:

views:

91

answers:

1

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.

+2  A: 

Hi Mario,

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

}
Rusty
I like the sound of that! I'll try it out. Thank you.
Mario Marinato -br-