From b9ebffd832a3d973819bdb00b10b0a27cd2a0d26 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 1 May 2020 19:28:44 +0200 Subject: [PATCH] Set also wxPGEditor items while changing wxPGProperty choices If we replace current set of choices when editor is active we need also replace editor items. Closes #18741. --- src/propgrid/property.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 4237a1fc95..763042fefd 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -2091,19 +2091,30 @@ bool wxPGProperty::SetChoices( const wxPGChoices& choices ) // Property must be de-selected first (otherwise choices in // the control would be de-synced with true choices) wxPropertyGrid* pg = GetGrid(); - if ( pg && pg->GetSelection() == this ) + bool isSelected = pg && pg->GetSelection() == this; + if ( isSelected ) + { pg->ClearSelection(); + } m_choices.Assign(choices); - + if ( isSelected ) { - // This may be needed to trigger some initialization - // (but don't do it if property is somewhat uninitialized) - wxVariant defVal = GetDefaultValue(); - if ( defVal.IsNull() ) - return false; + wxWindow* ctrl = pg->GetEditorControl(); + if ( ctrl ) + GetEditorClass()->SetItems(ctrl, m_choices.GetLabels()); + } + // This may be needed to trigger some initialization + // (but don't do it if property is somewhat uninitialized) + wxVariant defVal = GetDefaultValue(); + if ( !defVal.IsNull() ) SetValue(defVal); + + if ( isSelected ) + { + // Recreate editor + pg->DoSelectProperty(this, wxPG_SEL_FORCE); } return true;