0

次の行を含む次のテーブルを SWT でレンダリングしようとしています。

名前1 | anotherProperty |BUTTON1(EDIT) BUTTON2(REMOVE) BUTTON3(DEACTIVATE)

SWT - Tableviewer を使用してテーブルの列に削除ボタンを追加すると、列ごとにボタンを1 つだけレンダリングできました。

これを行う方法はありますか?

4

1 に答える 1

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();
     }
  });
于 2013-01-14T10:56:03.547 に答える