From 3e22c6c621032212807b9de6a93768bfcf82f500 Mon Sep 17 00:00:00 2001 From: Simon Shirley Date: Fri, 9 Dec 2022 15:54:23 +0000 Subject: [PATCH] Temporarily store the DisplayMember value and re-apply after _internalSource.Dispose() call --- DropDownControls/GroupedComboBox/GroupedComboBox.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DropDownControls/GroupedComboBox/GroupedComboBox.cs b/DropDownControls/GroupedComboBox/GroupedComboBox.cs index 16e5138..3767bf1 100644 --- a/DropDownControls/GroupedComboBox/GroupedComboBox.cs +++ b/DropDownControls/GroupedComboBox/GroupedComboBox.cs @@ -127,10 +127,16 @@ private enum RedrawWindowFlags : uint { return (_bindingSource != null) ? _bindingSource.DataSource : null; } set { + // temporarily store the DisplayMember value as it is lost on _internalSource.Dispose() + string _displayMember = DisplayMember; + if (_internalSource != null) _internalSource.Dispose(); _internalSource = null; - if (value != null) { + // restore the lost DisplayMember value + DisplayMember = _displayMember; + + if (value != null) { // wrap the object in a binding source and listen for changes _bindingSource = new BindingSource(value, String.Empty); _bindingSource.ListChanged += new ListChangedEventHandler(mBindingSource_ListChanged);