【问题标题】:How do I change the index of a TableItem?如何更改 TableItem 的索引?
【发布时间】:2009-07-29 20:40:59
【问题描述】:

在 SWT 表中,我有许多 TableItem。 我想将其中一个从索引 X 移动到索引 Y。 有没有办法做到这一点?怎么样?

谢谢。

【问题讨论】:

    标签: java eclipse swt


    【解决方案1】:

    我认为没有直接的方法可以做到这一点。但作为一种解决方法,请尝试以下方法。我曾经使用过类似的东西。

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

    【讨论】:

    • 我喜欢这样的声音!我会尝试一下。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2023-03-14
    • 2013-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    • 2017-08-20
    • 1970-01-01
    相关资源
    最近更新 更多