From f6fc052ae5c77cbf627d9d5f076ad93cd3a3e5a5 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 17 Oct 2006 18:21:05 +0000 Subject: [PATCH] SetSelection(wxNOT_FOUND) now works correctly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42081 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/univ/combobox.cpp | 11 ++++++----- src/univ/listbox.cpp | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/univ/combobox.cpp b/src/univ/combobox.cpp index 28ae78ee6d..89130b4e3c 100644 --- a/src/univ/combobox.cpp +++ b/src/univ/combobox.cpp @@ -145,9 +145,9 @@ void wxComboListBox::SetStringValue(const wxString& value) { if ( !value.empty() ) { - if (FindString(value) != wxNOT_FOUND) - wxListBox::SetStringSelection(value); - } + if (FindString(value) != wxNOT_FOUND) + wxListBox::SetStringSelection(value); + } else wxListBox::SetSelection(-1); } @@ -386,10 +386,11 @@ int wxComboBox::FindString(const wxString& s, bool bCase) const void wxComboBox::SetSelection(int n) { - wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::Select") ); + wxCHECK_RET( (n == wxNOT_FOUND || IsValid(n)), _T("invalid index in wxComboBox::Select") ); GetLBox()->SetSelection(n); - if ( GetTextCtrl() ) GetTextCtrl()->SetValue(GetLBox()->GetString(n)); + if ( GetTextCtrl() ) + GetTextCtrl()->SetValue(GetLBox()->GetString(n)); } int wxComboBox::GetSelection() const diff --git a/src/univ/listbox.cpp b/src/univ/listbox.cpp index a2697e5b41..7657a08ac6 100644 --- a/src/univ/listbox.cpp +++ b/src/univ/listbox.cpp @@ -483,6 +483,7 @@ void wxListBox::DoSetSelection(int n, bool select) // selecting an item in a single selection listbox deselects // all the others DeselectAll(); + return; } m_selections.Add(n); -- 2.47.2