Avoid an assert in wxComboBox when setting default values that don't

exist in the list of choices.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-09-17 00:46:37 +00:00
parent e3bd1146c7
commit 00924b9de2

View File

@@ -1353,15 +1353,15 @@ void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
m_startValue = grid->GetTable()->GetValue(row, col);
if (m_allowOthers)
Combo()->SetValue(m_startValue);
size_t count = m_choices.GetCount();
for (size_t i=0; i<count; i++)
else
{
if (m_startValue == m_choices[i])
{
Combo()->SetSelection(i);
break;
}
// find the right position, or default to the first if not found
int pos = Combo()->FindString(m_startValue);
if (pos == -1)
pos = 0;
Combo()->SetSelection(pos);
}
Combo()->SetInsertionPointEnd();
Combo()->SetFocus();
@@ -1377,7 +1377,10 @@ bool wxGridCellChoiceEditor::EndEdit(int row, int col,
grid->GetTable()->SetValue(row, col, value);
m_startValue = wxEmptyString;
if (m_allowOthers)
Combo()->SetValue(m_startValue);
else
Combo()->SetSelection(0);
return changed;
}