X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b4a11fe85cb632368ba8426204598806460b7679..658741180583e3219bdd26b83a798cf3c8a59df7:/src/msw/choice.cpp?ds=sidebyside diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 9eec9c2332..7b73e6f6f1 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -158,6 +158,21 @@ bool wxChoice::CreateAndInit(wxWindow *parent, return true; } +void wxChoice::SetLabel(const wxString& label) +{ + if ( FindString(label) == wxNOT_FOUND ) + { + // unless we explicitly do this here, CB_GETCURSEL will continue to + // return the index of the previously selected item which will result + // in wrongly replacing the value being set now with the previously + // value if the user simply opens and closes (without selecting + // anything) the combobox popup + SetSelection(-1); + } + + wxChoiceBase::SetLabel(label); +} + bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,