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 Dave,
Too bad, but thank you for your answer. I've posted
http://ideas.infragistics.com/forums/192359-windows-forms/suggestions/5943952-ultracomboeditor-in-checkbox-mode-allow-checking
and
http://ideas.infragistics.com/forums/192359-windows-forms/suggestions/5944101-provide-firstrow-firstindex-scrolltop-whatev
Best,Hans
Hello Hans,
Thank you for your response.
It is currently not possible to do what you described. I recommend posting it on http://ideas.infragistics.com as a new Product Idea so our product management team knows about it.
Please excuse the delay. I have not been able to isolate the 5px drop-down issue in a small sample project, but our requirements have changed in the meantime, so that we do not need a solution for this anymore.
However, we still need a solution for the selection issue that is demostrated in the sample project in the initial post: checking (or even unchecking!) a checkbox in the drop-down list selects that item. With a bit of hacking I've been able to preserve (or rather restore) the selection, but restoring the SelectedIndex programmatically scrolls the restored item to the top.
To see this, run the sample project, drop the list down, check item #10, scroll down further (using the mouse wheel) and check item #30. You'll see that the list scrolls item #10 to the top.
How can I suppress the scrolling, or alternatively, how can I retrieve and restore the scroll position, so that I can check and uncheck item #30 (and keep item #10 selected) without any scrolling?
Thanks!
Hans
In order to proceed further with this issue, I will need a sample project which reproduces the issue. You can attach the zipped up project by selecting the Options tab when editing your post.
Thank you for your reply.
I can see how this could be a problem, but not in this case. We had actually deferred the DropDown() call into an OnIdle handler to make sure that the UltraComboEditor had properly recovered from the changes and was ready. This used to work under 2011.2, but not anymore under 2013.2.