2015-06-28 21 views
0

如何在SWTTable如何在SWT表的特定行

在一个特定的行索引更新TableItem更新数据我打开一个完整的数据表,双击它加载它们在多个组件并想将信息更新到同一行。

有人可以帮助我。

回答

3

为了更新一排,使用相应的TableItem()setText()setImage()方法。

例如:

TableItem item = table.getSelection()[ 0 ]; // assumes a single selected item 
item.setText(1, "update first column"); 
// or 
item.setText(new String[]{ "col 1 value", "col 2 value" }); 
// or, for a single-columned table 
item.setText("updated value"); 
+0

谢谢你的帮助。 – Rabin

2

使用

public TableItem(Table parent, int style, int index) 

构造。这使您可以指定新项目的行索引。

这是假设您只是使用TableTableItem而不是JFace TableViewer

+0

是的,谢谢。 – Rabin

+0

我想替换它。这只是将原来的一行向下移动。有什么建议么? – Rabin

+2

其他答案涵盖替换现有条目 –