Forum: wxRuby Grid Cell Background Colour

Posted by Norbert Lange (lange_n)
on 2012-05-18 00:02
On to my next question.  :-)

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
Posted by Norbert Lange (lange_n)
on 2012-05-18 00:21
I should probably also have mentioned, the Table object is derived from 
Wx::GridTableBase.
Posted by Norbert Lange (lange_n)
on 2012-05-18 19:15
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.