tags:

views:

449

answers:

1

I've got a wxGrid that I populate dynamically. I'd like to store some information with each row that shouldn't be displayed to the user. What is the best way to associate data with a row? Should I just create a hidden column or is there a better way?

+3  A: 

Creating a hidden column is the fastest, but indeed a very ugly method. If you can justify the effort, then you should better create your own grid table base class. Your own wxGridTableBase-derived class can hold any information you need it to, without the need to show it in the grid. Unfortunately the documentation for that class is sparse or nearly non-existent.

For an example see the grid demo in the wxWidgets samples directory, specifically the BugsGridTable class. What you will notice is that you do not necessarily store the strings that the grid will display, but you can format your data in the GetValue() method. This can be a lot better, both in terms of memory consumption, and because you can change the format of displayed data on-the-fly.

The switch to a custom grid table base class has had a big impact on speed, memory consumption and functionality for the result set data grid of FlameRobin, an administration tool for the Firebird relational database. You can always check out its source code for how we use wxGrid.

mghie