When I click on a checkbox inside the drop-down list, the control not only toggles the state of the checkbox, but it also changes the SelectedItem. I need to suppress the latter. SelectedItem should only change when I click outside of the checkbox.
Here's my best effort:
using System; using System.Windows.Forms; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; namespace ComboTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); ((ICheckedItemList) ultraComboEditor1.Items.ValueList) .CheckStateChanged += OnCheckStateChanged; } private void OnCheckStateChanged( object sender, EditorCheckedListSettings.CheckStateChangedEventArgs checkStateChangedEventArgs ) { var priorSelectedItem = (ValueListItem) ((ValueList) sender).SelectedItem; if ( checkStateChangedEventArgs.Item != priorSelectedItem ) { _itemToRestore = priorSelectedItem; // unwanted change -> undo!
} } private void ultraComboEditor1_ValueChanged( object sender, EventArgs e ) { var editor = (UltraComboEditor) sender; if ( _itemToRestore != null && editor.SelectedItem != _itemToRestore ) { editor.SelectedItem = _itemToRestore; } _itemToRestore = null; } private ValueListItem _itemToRestore;
} }
Even though it's quite hackish, it used to work reasonably well in older versions of Infragistics, but in the current 13.2.20132.2016 the SelectedItem setter causes the drop-down to scroll the selected item to the top of the drop-down window, which is unacceptable.
Is there a better way to achieve the intended behavior, or is there at least a way to suppress or control the scrolling?
TIA!Hans
Hello Hans,
Thank you for your response.
If you're adding items to the UltraComboEditor after it's already been dropped down, the dropdown will not resize to show the new items. You need to add the items before the UltraComboEditor has dropped down in order for it to take those items into account when sizing the dropdown.
Hi Michael
The version that we used before 2013.2 was 2011.2, but it was part of a more complex set-up, so now that I reconsider it, I'm not 100% positive that the demo app really would have worked.
The real app involved on-the-fly adding and removing the checkboxes (requiring recreating the HWND) as well as emptying and re-adding the items. After updating to 2013.2 we've seen issues where the drop-down would be only five or so pixels high, even though it contained items (they were selectable with the keyboard!).
What we do in the real application is this: the user has a regular drop-down listbox with a few items plus a "More..." item. Clicking the "More..." item drops down a much larger list with checkboxes, where the user can check/uncheck the ones that he wants to see in the short list and/or select an item from the long list. Clicking a checkbox must not change the selection though. We got this to work under 2011.2.
I have now redesigned the implementation to use two different comboboxes, one on top of the other, to avoid switching CheckedListSettings.CheckBoxStyle. I got this to work, except for this last flaw in the demo app.
Thank you for looking into it!Hans
P.S. We have occasionally seen the 5-px-only drop-down issue on other comboboxes, too. Those never have checkboxes, but we do empty and refill the items. We haven't been able to track this down yet, but we will have to. If we can fix that, then we might be able to revert to the old implementation.
Hans,
Which version of Infragistics were you using before upgrading to 2013 volume 2?