Grid Cell Background Colour


#1

On to my next question. :slight_smile:

I’ve been trying to get the cell background colour to work for a
Wx::Grid
control. Setting a default background colour works, but using the
set_cell_background_colour method for an individual cell doesn’t.
Following is a short snippet of what I’m trying to do (essentially
highlight cells that don’t match):

columnNames = Array.[](“Col1”, “Col2”, “Col3”)
row1 = Array.[](“A”, “B”, “C”)
row2 = Array.[](“X”, “Y”, “Z”)
resultSet = Array.[](row1, row2)

table = Table.new(columnNames, resultSet)
grid = Wx::Grid.new(panel, -1)
grid.set_table(table)
@grid.set_cell_background_colour(1, 1, Wx::RED)

Any help is greatly appreciated.

Norbert


#2

I should probably also have mentioned, the Table object is derived from
Wx::GridTableBase.


#3

Update: I finally got this working. In case anyone else runs into the
same thing, I finally realized I needed to override the set_attr and
get_attr methods in my Table subclass.

Norbert