krm
krm

Reputation: 2106

Select only column header and no row in an SWT table after click on column header

I have an Eclipse SWT table. It contains multiple rows (with row headers) and multiple columns (with column headers). On click on a column header I want to deselect all rows and highlight only the column's header (or all cells of this column). Is that possible?

I already registered a listener for the column header's selection and am able to set the selection to the given column, but then it also always selects the first row automatically. I tried with SWT.FULL_SELECTION and SWT.SINGLE as the style of my table, but it only changes the way how the row is highlighted, but I want only to highlight the column's header (or optionally all cells of this column) and no rows.

Is it possible? Did anyone have the same problem?

Upvotes: 1

Views: 400

Answers (1)

Adam Horvath
Adam Horvath

Reputation: 1286

I ran into the same problem and I'm afraid you can't do that in SWT.

I solved by imitating the selection of a column; I colored the cells as if they were selected, and dropped the "real" selection.

You should extend your own TableViewer and override the getSelection() method to reflect that you now also have this imitated kind of selection. (And from a UX perspective, you should make sure that a copy command (i.e. Ctrl+C) behaves as users expect it.)

Upvotes: 1

Related Questions