I will need to create own wxGridCellRenderers and wxGridCellEditors in my proj.
So, I try to understand how it should work.
First, I've found that I need to use IncRef() before SetColAttr().
Now,I have another error when I close an app:
"Assert GetEventHandler()==this failed in ~wxWindowBase: any pushed event handlers must have been removed".
In MyFrame::MyFrame I do:
Code: Select all
dg = new wxGrid(pn1, ID_GRID4, wxPoint(56,48), wxSize(264,216), 0, _T("ID_GRID4"));
dg->CreateGrid(4,0);
dg->SetRowLabelSize(20);
dg->SetColLabelSize(20);
dg->DisableDragRowSize();
dg->SetDefaultCellBackgroundColour(wxColour(128,128,128));
dg->AppendCols(3);
dg->SetColLabelValue(0,wxT("A"));
dg->SetColLabelValue(1,wxT("B"));
dg->SetColLabelValue(2,wxT("C"));
wxGridCellAttr* pAttr = new wxGridCellAttr;
pAttr->IncRef();
pAttr->SetBackgroundColour(wxColour(25,255,255));
wxGridCellAttr* pAttrBool = new wxGridCellAttr;
pAttrBool->IncRef();
pAttrBool->SetBackgroundColour(wxColour(200,155,255));
pAttrBool->SetRenderer(new wxGridCellBoolRenderer());
pAttrBool->SetEditor(new wxGridCellBoolEditor());
pAttrBool->SetAlignment(wxALIGN_CENTRE,wxALIGN_CENTRE);
dg->SetColAttr(0,pAttr);
dg->SetColAttr(1,pAttr);
dg->SetColAttr(2,pAttrBool);
If I don't touch cells with Editor, all is ok too.
I suppose, I should do something in MyFrame::~MyFrame?
Thanks.