Page 1 of 1

How to create two rows of columns labels in wxGrid?

Posted: Thu Mar 09, 2006 10:47 am
by Bundy
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

Posted: Thu Mar 09, 2006 11:09 am
by phlox81
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.

Posted: Fri Mar 10, 2006 9:20 am
by hgiritzer
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.

Posted: Fri Mar 10, 2006 9:30 am
by Mortis
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.

Posted: Sun Mar 12, 2006 12:16 am
by emarti
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!

Posted: Sun Mar 12, 2006 9:50 am
by hgiritzer
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.

Posted: Sun Mar 12, 2006 11:01 am
by emarti
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!

Posted: Mon Mar 13, 2006 8:19 pm
by Arakageeta1
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.

Posted: Tue Mar 14, 2006 8:10 am
by hgiritzer
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.