Bug in GridCellEnumRenderer ?
Mark Erbaugh
mark at microenh.com
Tue Feb 5 07:39:00 PST 2008
I think I've found a bug in the C++ code to GridCellEnumRenderer.
The following code is from gridctrl.cpp/
Here's the code from GridCellEnumEditor::BeginEdit (which works):
if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) )
{
m_startint = table->GetValueAsLong(row, col);
}
else
{
wxString startValue = table->GetValue(row, col);
if (startValue.IsNumber() && !startValue.empty())
{
startValue.ToLong(&m_startint);
This code attempts to read the cell value as a long, which (see my other
post) isn't working. If it can't read the value as a long it calls
GetValue which should return a string and converts the string to a long.
Subsequent code uses this value as an index into the drop down list of
the editor.
Here's corresponding code for GridCellEnumRenderer::GetString:
if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) )
{
int choiceno = table->GetValueAsLong(row, col);
text.Printf(_T("%s"), m_choices[ choiceno ].c_str() );
}
else
{
text = table->GetValue(row, col);
If it is unable to get the value as a long, it simply returns the string
value from the table. It doesn't use that as an index into the m_choices
array.
This behavior is what I see in my grid. The cell when it is not being
edited displays a number (which is the index into the list). When you
edit the cell, the editor correctly displays the corresponding text
value.
Mark
More information about the wxpython-users
mailing list