Is there any way to change the border colour of a column in a wxGrid?
Currently if a column in the grid is selected, the background colour of the column is changed, however I would rather change the border colour of the column so that I can use the background colour to indicate other properties of cell contents.
Any ideas on how this can be achieved?
Grid column border colour Topic is solved
Grid column border colour
Using Win XP, Dev C++ 4.9.9.2 wx-beta 6.9
-
- wxWorld Domination!
- Posts: 1471
- Joined: Tue Nov 14, 2006 7:58 am
- Location: Saint-Petersburg, Russia
Hi,
currently wxGrid uses one colour for all grids (borders), but you can create custom class derived from wxGrid and redefine virtual method
currently wxGrid uses one colour for all grids (borders), but you can create custom class derived from wxGrid and redefine virtual method
Code: Select all
virtual wxPen GetColGridLinePen(int col);
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
-
- wxWorld Domination!
- Posts: 1471
- Joined: Tue Nov 14, 2006 7:58 am
- Location: Saint-Petersburg, Russia
Ok,Peterj wrote:Thanks for your reply. Can you give me an example please?
Code: Select all
class MyGrid : public wxGrid
{
public:
MyGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr)
: wxGrid(parent, id, pos, size, style, name), m_sel_pen(*wxBLACK_PEN) {}
void SetColSelPen(const wxPen& pen) { m_sel_pen = pen; }
wxPen GetColSelPen() const { return m_sel_pen; }
wxPen GetColGridLinePen(int col)
{
wxArrayInt sels = GetSelectedCols();
if( sels.Index(col) != wxNOT_FOUND ) // Selected col
return m_sel_pen;
else // Not selected, default pen
return GetDefaultGridLinePen();
}
private:
wxPen m_sel_pen;
};
.......
MyGrid* grid = new MyGrid(this, wxID_ANY);
grid->SetColSelPen(wxPen(wxColour(255, 0, 0), 2)); // For example :)
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10