Reputation: 21
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
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