2013-01-13 17 views

回答

3

以與添加單個按鈕相同的方式,您也可以添加多個按鈕,但對於這些按鈕,您將需要額外的容器。你可以嘗試下面的東西:

col.setLabelProvider(new ColumnLabelProvider() { 
    @Override 
    public void update(ViewerCell cell) { 
    TableItem item = (TableItem) cell.getItem(); 

    Composite buttonPane = new Composite(getTable(), SWT.NONE); 
    buttonPane.setLayout(new FillLayout()); 

    Button button = new Button(buttonPane,SWT.NONE); 
    button.setText("Edit"); 

    button = new Button(buttonPane,SWT.NONE); 
    button.setText("Remove"); 

    button = new Button(buttonPane,SWT.NONE); 
    button.setText("Deactivate"); 

    TableEditor editor = new TableEditor(getTable()); 
    editor.grabHorizontal = true; 
    editor.grabVertical = true; 
    editor.setEditor(buttonPane, item, columnIndex); 
    editor.layout(); 
    } 
    }); 
+0

謝謝!有效。 – davidfdr

+0

這可行,但你真的不需要複合...你可以創建與表的按鈕。 –