How to create two rows of columns labels 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
Bundy
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Apr 29, 2005 9:46 am
Location: Poland

How to create two rows of columns labels in wxGrid?

Post by Bundy » Thu Mar 09, 2006 10:47 am

I can't find way to create two rows of columns labels. It is simple in Borland (for example). Is it something similar in wxGrid?

I need something like this:

Code: Select all

+--------------------------------------------------------------+
| row id  |       first execution     |    second execution    |
+--------------------------------------------------------------+
|         |  width      |    height   |  width    |    height  |
+--------------------------------------------------------------+    
|         |             |             |           |            |
+--------------------------------------------------------------+
|         |             |             |           |            |
+--------------------------------------------------------------+
|         |             |             |           |            |
+--------------------------------------------------------------+
Ofcourse, the best will be something like this:

Code: Select all

+--------------------------------------------------------------+
|         |       first execution     |    second execution    |
| row id  |----------------------------------------------------+
|         |  width      |    height   |  width    |    height  |
+--------------------------------------------------------------+    
|         |             |             |           |            |
+--------------------------------------------------------------+
|         |             |             |           |            |
+--------------------------------------------------------------+
|         |             |             |           |            |
+--------------------------------------------------------------+
Regards
Last edited by Bundy on Thu Mar 09, 2006 11:30 am, edited 2 times in total.
"Fate rewards prepared mind"

Quote from movie "Liberator 2"

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Thu Mar 09, 2006 11:09 am

hm, what sense could that make ?
You might try adding \n to your Columnheading
for a second line. But 2 rows of Columnheading,
I think its not yet implemented in wxGrid.

hgiritzer
Knows some wx things
Knows some wx things
Posts: 34
Joined: Wed Mar 09, 2005 10:24 am
Location: Austria

Post by hgiritzer » Fri Mar 10, 2006 9:20 am

I'd like to have a similar feature, a possibility to freeze the first n rows of a grid like it can be done with MS Excel.

These rows will always stay on top, even when scrolling down the rest of the grid.

So, you could treat them as additional column headers to show additional information or whatever.

I have set a Bounty on implementing such a feature, but unfortunately nobody has claimed it yet. :(
Maybe it's really difficult to code, I don't know.

Mortis
Earned a small fee
Earned a small fee
Posts: 18
Joined: Mon Mar 06, 2006 1:47 pm
Location: Sint Oedenrode, Netherlands
Contact:

Post by Mortis » Fri Mar 10, 2006 9:30 am

hgiritzer wrote:I have set a Bounty on implementing such a feature, but unfortunately nobody has claimed it yet. :(
Maybe it's really difficult to code, I don't know.
You might want to look at the sources of OpenOffice.org, because OpenOffice.org Calc does implement this feature (like Excel does), do keep in mind though that OpenOffice.org is licensed as LGPL when you start copying code instead of simply studying it and learning from it.
"The true sign of intelligence is not knowledge but imagination."

"Ai! Lauri

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Sun Mar 12, 2006 12:16 am

Hi,
According to me, You must use box.

Please, look grid sample at the wxWidgets sample folder. (lines 338-340)

Code: Select all


    grid->SetCellSize(7, 1, 3, 4);
    grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
    grid->SetCellValue(7, 1, _T("Big box!"));

grid->SetCellSize(x coordinate, y coord., width, height);

Enjoy with grid!
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

hgiritzer
Knows some wx things
Knows some wx things
Posts: 34
Joined: Wed Mar 09, 2005 10:24 am
Location: Austria

Post by hgiritzer » Sun Mar 12, 2006 9:50 am

Yes, there are functions for merging cells.
But they are only useful on data cells, not on the column (or row) headers.

I don't know any currently available method of adding a second row of column headers or forcing some of the first data rows to stay on top (visible), which would for some applications do a similar job as having multiple column header rows.

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Sun Mar 12, 2006 11:01 am

You're right for using data cell only not column label. If column labels are not visible, you must use data cell like column label with merge cell :)

it is only idea!
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

Arakageeta1
Knows some wx things
Knows some wx things
Posts: 38
Joined: Tue Oct 18, 2005 12:26 am

Post by Arakageeta1 » Mon Mar 13, 2006 8:19 pm

I think emarti is right. You're going to have to use the cells themselves to do this sort of labeling instead of the actual grid labels. You can make them look kinda like labels by shading them with background colors. I'm not sure if the stock wxGrid allows you to merge cells. Does it? If not, you'll want to look into using wxSheet instead. wxSheet is a 3rd party wx widget. I think you can find it on sourceforge somewhere. wxSheet also allows you to split the grid into two panes-- this would allow you to scroll down while still keeping your label cells visible.

hgiritzer
Knows some wx things
Knows some wx things
Posts: 34
Joined: Wed Mar 09, 2005 10:24 am
Location: Austria

Post by hgiritzer » Tue Mar 14, 2006 8:10 am

I have taken a quick look onto it:
http://wxcode.sourceforge.net/showcomp.php?name=wxSheet

The package can be downloaded here:
https://sourceforge.net/project/showfil ... _id=343619

In short:
wxSheet has similar functions like wxGrid, but it is not backwards compatible.
Many features were converted, but as far as I could see database driven tables are not (yet) supported (as they are with wxGrid).

Anyway, I'll take a deeper look at wxSheet.

Post Reply