Is it possible to add a Remove button to a cell in a table?
I have a table with 5 columns, I would like to add a 6th column. I want the 6th column to have
One important thing to the chosen answer is that you should not create an instance of TableEditor on every update method call it will slow down the performance or even make the application unresposnive.
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem) cell.getItem();
Button button;
if(buttons.containsKey(cell.getElement()))
{
button = buttons.get(cell.getElement());
}
else
{
button = new Button((Composite) cell.getViewerRow().getControl(),SWT.NONE);
button.setText("Remove");
buttons.put(cell.getElement(), button);
TableEditor editor = new TableEditor(item.getParent());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(button , item, cell.getColumnIndex());
editor.layout();
}
}