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,
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.
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.
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.