Muliti-Line Lables in wxGrid

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sam_des
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Aug 30, 2017 4:55 am

Muliti-Line Lables in wxGrid

Post by sam_des » Sat Sep 28, 2019 4:32 am

Hello,

Is there is simple way of having Multi-line row or column labels in wxGrid?

Code: Select all

Instead of 
| COL-1 | COL-2 | BIG BIG BIG COL-3 | COL-4 |

Like this (with center alignment)-
|       |        |         BIG BIG      |       |
| COL-1 | COL-2  |       BIG COL-3      | COL-4 |
|       |        |                      |       |

No fancy stuff, just need to reduce the column width to fit the table without scrollbars. \n does not work.

Thanks in advance,
sam_des

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 132
Joined: Tue Jun 07, 2016 1:07 pm

Re: Muliti-Line Lables in wxGrid

Post by Kvaz1r » Sat Sep 28, 2019 5:24 am


sam_des
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Aug 30, 2017 4:55 am

Re: Muliti-Line Lables in wxGrid

Post by sam_des » Sat Sep 28, 2019 7:48 am

Hi,

Thanks for the reply, but that's not what I wanted to achieve.

This wxGrid with Column lables, I am trying to achieve 2 row label using \n, which doesn't work,
MultiLine-2.png
MultiLine-2.png (2.9 KiB) Viewed 95 times
& This is what I actually want, (this is from QtTableWidget, with \n you can have multiple lines)
MultiLine-1.png
MultiLine-1.png (3.14 KiB) Viewed 95 times
Actual data cells are single row, just labels can be multi-line.

Hope that clarifies my question,
sam_des

User avatar
doublemax
Moderator
Moderator
Posts: 14172
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Muliti-Line Lables in wxGrid

Post by doublemax » Sat Sep 28, 2019 9:03 am

This works for me:

Code: Select all

grid->UseNativeColHeader( false );
grid->SetColLabelValue(0, "line 1\nline 2");
Use the source, Luke!

sam_des
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Aug 30, 2017 4:55 am

Re: Muliti-Line Lables in wxGrid

Post by sam_des » Sat Sep 28, 2019 11:49 am

doublemax wrote:
Sat Sep 28, 2019 9:03 am
This works for me:

Code: Select all

grid->UseNativeColHeader( false );
grid->SetColLabelValue(0, "line 1\nline 2");
Thanks a lot...

sam_des

Post Reply