Can you set multiple wxGrid Colum Attributes?

Riccardo Cohen rcohen at articque.com
Thu Jan 10 00:04:10 PST 2008


you should set all attributes on the same wxGridCellAttr before calling 
SetColAttr

Bob wrote:
> 
> I have a wxGrid with three columns. I want all of the grid
> to be ReadOnly. If I do this:
> 
> m_LogGrid->ClearGrid();
> 
> wxGridCellAttr *ReadOnlyAttr = new wxGridCellAttr;// Remove all previous 
> background colors, and set all of grid ReadOnly
> ReadOnlyAttr->SetReadOnly();
> m_LogGrid->SetColAttr( LogGridColDate, ReadOnlyAttr );
> m_LogGrid->SetColAttr( LogGridColEventInHuman, ReadOnlyAttr );
> m_LogGrid->SetColAttr( LogGridColEvent, ReadOnlyAttr );
> 
> and do not do this:
> 
> wxColour default_cell_background_color = 
> m_LogGrid->GetDefaultCellBackgroundColour();
> wxGridCellAttr *ColorAttr = new wxGridCellAttr;// Remove all previous 
> background colors, and set all of grid ReadOnly
> ColorAttr->SetBackgroundColour( default_cell_background_color );
> m_LogGrid->SetColAttr( LogGridColDate, ColorAttr );
> m_LogGrid->SetColAttr( LogGridColEventInHuman, ColorAttr );
> m_LogGrid->SetColAttr( LogGridColEvent, ColorAttr );
> 
> the gird is ReadOnly as I want, but if I do try to set the background color
> of the grid as well, then the grid is no longer read only.
> 
> Is it possible to set more than one attribute on a column?
> 
> Also the setting of the default background color doesn't seem to work.
> 
> If I load my data in to the grid, which colors each cell depending on
> the data loaded I get colored cells as I want. However when
> I try to return all of the cell backgrounds back to their
> default color, when I load new data next time, the old
> colors remain. How do I restore the entire grid
> to its default background color?
> 
> This is with wx287, and Digital Mars Compiler, on Windows XP.
> 
> 

-- 
Très cordialement,

Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49




More information about the wx-users mailing list