Amruta L
Amruta L

Reputation: 21

How to center align nebula grid column group header

I want to center align the column group text, so provided the SWT.CENTER style while creating the "GridColumnGroup" similar to the way we provide for GridColumn. However even after providing the CENTER style, column group text is shown Left aligned.

Code I tried:

GridColumnGroup columnGroup = new GridColumnGroup(grid,SWT.CENTER);
columnGroup.setText("Column Group");
GridColumn column1 = new GridColumn(columnGroup,SWT.CENTER);
column1.setText("Column 1");
GridColumn column2 = new GridColumn(columnGroup,SWT.CENTER);
column2.setText("Column 2");

[Nebula Grid column and column group rendering with above code ] 2 Any idea what I am missing here ?

Thanks

Upvotes: 2

Views: 196

Answers (1)

Andrey Kachow
Andrey Kachow

Reputation: 1126

The style SWT.CENTER does not propagate to the GridHeaderRenderer of the column group. However, void setHorizontalAlignment​(int alignment) method of GridHeaderRenderer allows you to center the text.

columnGroup.getHeaderRenderer().setHorizontalAlignment(SWT.CENTER);

Upvotes: 0

Related Questions