wxGrid, wxMSW2.8.0rc1 and "invalid value for a cell with bool editor!"
Volker Bartheld
dr_versaeg at freenet.de
Mon Dec 18 11:59:05 PST 2006
Hello!
I'm running the little wxGrid example prog below and get the "invalid
value for a cell with bool editor!"-assertion for a click on every odd
cell checkbox. cellval as used in %WXDIR%\src\generic\grid.cpp:1343 is
"0" and I don't see a reason why this should be considered invalid.
Strange that the code
wxString cellval( grid->GetTable()->GetValue(row, col) );
if ( cellval == ms_stringValues[false] )
m_startValue = false;
else if ( cellval == ms_stringValues[true] )
m_startValue = true;
else
{
// do not try to be smart here and convert it to true or false
// because we'll still overwrite it with something different and
// this risks to be very surprising for the user code, let them
// know about it
wxFAIL_MSG( _T("invalid value for a cell with bool editor!") );
}
}
refers to static wxString ms_stringValues[2]; element via a boolean
index but obviously the comparison fails. This used to work with
wxW2.7.0 if I remember correctly.
Am I missing something here?
Thanks for clarifying.
Volker
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/grid.h>
class MyDialog : public wxDialog
{
public:
MyDialog::MyDialog() : wxDialog(NULL, wxID_ANY, wxT("wxGrid"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
wxBoxSizer *pSizerV=new wxBoxSizer( wxVERTICAL );
wxGrid* pGrid=new wxGrid(this, wxID_ANY, wxDefaultPosition, wxSize(180, 256));
pGrid->CreateGrid(8, 1, wxGrid::wxGridSelectRows);
pGrid->SetColLabelValue(0, wxT("Options"));
for(int i=0; i<pGrid->GetNumberRows(); i++)
{
pGrid->SetCellRenderer(i, 0, new wxGridCellBoolRenderer);
pGrid->SetCellEditor(i, 0, new wxGridCellBoolEditor);
pGrid->SetCellValue(i, 0, (i%2)?wxT("1"):wxT("0"));
}
pSizerV->Add(pGrid);
SetSizer(pSizerV);
pSizerV->SetSizeHints(this);
}
void MyDialog::OnClose(wxCloseEvent&) { Destroy(); }
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(MyDialog,wxDialog)
EVT_CLOSE(MyDialog::OnClose)
END_EVENT_TABLE()
class MyApp: public wxApp
{
public:
bool MyApp::OnInit()
{
MyDialog* TheDialog=new MyDialog();
TheDialog->Show();
return true;
}
};
IMPLEMENT_APP(MyApp)
__
Mail replies to/an V B A R T H E L D at G M X dot D E
More information about the wx-users
mailing list