Posted by:xiaomage234
Posted on:2004-10-30 15:34
参考一下吧,只是一个片段~~
private TableViewer getTableViewer(Composite composite) {
TableViewer tv = null;
tv = CheckboxTableViewer.newCheckList(composite, SWT.MULTI
| SWT.DROP_DOWN);
Table table = tv.getTable();
table.setHeaderVisible(true);
TableColumn column1 = new TableColumn(table, SWT.LEFT, 0);
column1.setText("ids");
column1.setWidth(100);
TableColumn column3 = new TableColumn(table, SWT.RIGHT, 2);
column3.setText("owners");
column3.setWidth(100);
String[] columnNames = new String[] { "id", "owner"};
tv.setUseHashlookup(true);
tv.setColumnProperties(columnNames);
//Column 1 : Completed (Checkbox)
CellEditor[] editors = new CellEditor[2];
CheckboxCellEditor checkbox = new CheckboxCellEditor(table, SWT.CHECK);
editors[0] = checkbox;
//Column 2 : Owner (Combo Box)
editors[1] = new ComboBoxCellEditor(table,
new String[] { "A", "B", "C" });
tv.setCellEditors(editors);
tv.setContentProvider(new TaskTableContentProvider());
tv.setLabelProvider(new TaskTableLabelProvider());
tv.setCellModifier(new TableCellModifier(tv));
tv.setInput("");
return tv;
}