Combining Column and Cell Attributes

Hi, I have a following question.

In the program I use a grid, which colors cells in “chessboard” like pattern (i.e., one could easily distinguish different cells).
This grid is a virtual table, which may contain tens of thousands of rows.

Now I would like to make some of the columns in the Grid read only.

Examples that I have found show, that this could be done via usage of the column attributes (SetColAttr).

However, I would like to preserve background colors of cells, which are different for each cell.

Previously I provided cell attributes to the cell via overriding wxGridBase.GetAttr method.

Now, in order to provide correct cell Attributes, I need to combine cell attributes (containing font and backrgound color) and column attributes (containining read only properties).
I was not able to find examples, which show, how this could be done.

So, my question is:
what is the proper way of combining cell level and column level grid cell attributes?

Many Thanks in advance


You don’t need the column attributes.

Try these:

  • before your GetAttr method returns an attribute, call attribute.SetReadOnly()
  • bind a handler for EVT_GRID_EDITOR_SHOWN and call event.Veto() in the handler


Hi, Dietmar.

Thank you for the answer.

I ended up adding seperate combination of attributes for readonly columns (same as the one for editable, but with readOnly option set). The problem with this approach is that the number of grid cell atributes instances grows twice

Many Thanks