Reputation: 514
The CheckboxTableViewer allows creation a single checklist.
But how do I put the header of such a column since the column itself is not created by a TableColumn.
tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.SINGLE| SWT.BORDER | SWT.FULL_SELECTION);
tableViewer.add(checkListNames.get(0));
tableViewer.add(checkListNames.get(1));
tableViewer.add(checkListNames.get(2));
tableViewer.add(checkListNames.get(3));
tableViewer.add(checkListNames.get(4));
tableViewer.add(checkListNames.get(5));
final Table table = tableViewer.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
System.out.println(table.getColumnCount()); // this returns a zero
table.setHeaderVisible(true);
table.setLinesVisible(true);
Upvotes: 1
Views: 341
Reputation: 111142
You need to use TableLayout
and TableViewerColumn
to define a column so you can set the header text.
The minimum code would be:
TableLayout layout = new TableLayout();
TableViewerColumn col = new TableViewerColumn(tableViewer, SWT.LEAD);
col.getColumn().setText("Text");
layout.addColumnData(new ColumnWeightData(100));
table.setLayout(layout);
Upvotes: 1