We have a screen setup such that we have a text box that lets the user type in a numeric value and based on that, we populate an UltraListView. Currently, the code is structured so that on the textbox's leave event, we get our data from the database and then populate the UltraListView.
The problem that we run into is that if the user types in a value into this text box, and selects an item that will no longer be part of the UltraListView's data, we get the following error:
An UltraListViewItem cannot be selected if it does not belong to this control's Items collection.
at Infragistics.Win.UltraWinListView.UltraListViewSelectionManager.SelectItem(UltraListViewItem item, Boolean clearExistingSelection, Boolean enforceUIRules) at Infragistics.Win.UltraWinListView.UltraListView.Infragistics.Win.ISelectionManager.SelectItem(ISelectableItem item, Boolean forceToggle) at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo, Boolean forceDrag) at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo) at Infragistics.Win.SelectionStrategySingle.OnMouseMessage(ISelectableItem item, MouseMessageInfo& msginfo) at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseDown(MouseEventArgs e) at Infragistics.Win.UltraWinListView.UltraListView.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at OptiGlass.Program.Main(String[] args) in c:\Jobs\Product\Opti\Opti-Glass\GlassManager\Program.cs:line 27 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
I can probably try to mock up a simple example, just wondering if this was a known issue or if there is an obvious workaround.
Thanks,
Steve
Hello Steve,
I have not seen this behavior occur. But if the item is no longer in the database, what do you wish to be the expected behavior? It would be great if you can provide a mockup sample. That way our team can analyze it and send it to our developers further debugging. Thanks.
Hi Michael,
Thanks for the quick response. I mocked up an oversimplified version of what we're trying to do. Basically the form is an UltraListView, with a textbox above it:
using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_Leave(object sender, EventArgs e) { FillList(); } private void FillList() { try { Cursor = Cursors.WaitCursor; ulReleases.BeginUpdate(); ulReleases.Items.Clear(); ulReleases.SelectedItems.Clear(); for (int i = 0; i < Convert.ToInt32(this.textBox1.Text); i++) { Infragistics.Win.UltraWinListView.UltraListViewItem lvItem = ulReleases.Items.Add(i.ToString(), i.ToString()); } ulReleases.EndUpdate(); } finally { Cursor = Cursors.Default; } } } }
The textbox has a leave event that will need hooked in. If you type 15 into the box, hit the tab key, the list will fill. Then, type 1 into the box, but instead of tabbing off, click on item 10.
Try removing the begin/end update methods. It seems to improve the situation however I am unable type 0 and select the only available option. I will keep looking into this, but let me know what you think.
Thanks Michael,
That resolves the problem excepting in the case where the list is empty (looking forward to your answer there!).
I recommend that you use the text editor's ValueChanged event instead of the leave event because then your users won't be able to click on an item that no longer exists. You can also wrap a null check to make sure you updating the list items when a user types 0, like so
if (this.ultraTextEditor1.Value != null) {
for (int i = 0; i < Convert.ToInt32(this.ultraTextEditor1.Text); i++) { Infragistics.Win.UltraWinListView.UltraListViewItem lvItem = ultraListView1.Items.Add(i.ToString(), i.ToString()); }
}
Let me know if this helps.
Unfortunately that's not really an option since the list refresh results in a database hit, which could potentially bring a lot of results back, which could present a performance problem (at least forcing them to leave the cell gives them a chance to change their text).
Hello,
This issue has been addressed in service release versions 2014.1, WinForms_13.2.20132.2042, WinForms_13.1.20131.2116.
This service release is now available under your account at the Infragistics Website. To download the service release, log in to ‘Account’ and select ‘Keys & Downloads’. Select the appropriate tab for this product; then the license key. The available service releases (Hot Fixes) should now be listed on the page.
Let me know if you have any questions regarding this matter.
I have opened a private case for you so that I can link it to this development issue. This way you will be notified automatically when the dev. issue is updated. The case number is "CAS-131194-X0R7N6". You will see it located here: https://ko.infragistics.com/my-account/support-activity