I have two level treeview with grid look. When clicking on the parent row it needs to expand and make sure children nodes are in the view of the screen.
This works fine until user scrolls away and first element is not visible anymore. At that point if user tries to clicking on different parent node he get an error (screenshot attached):
"Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index"
Usually the error happens if child item of ParentA node active/seletected, and User Clicks on ParentB node. As soon as the Expanded or BringIntoView triggers, It errors out
I tried to refresh treeView, and put delay. Seemed to work at first but now I see it still happening. We're using version 12.1. Please help. The source code below
Dim prevNode As UltraTreeNode = Nothing
....
Private Sub tvOrders_AfterSelect(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinTree.SelectEventArgs) Handles tvOrders.AfterSelect
.....
If e.NewSelections.Count > 0 Then If TypeOf e.NewSelections(0).Tag Is SCE.SCEInterfaces.IOrder Then tvOrders.Refresh() Application.DoEvents() If prevNode IsNot Nothing AndAlso prevNode IsNot e.NewSelections(0) Then prevNode.Expanded = False End If e.NewSelections(0).Expanded = True If e.NewSelections(0).Nodes.Count > 0 Then e.NewSelections(0).Nodes(0).BringIntoView(True) Else e.NewSelections(0).BringIntoView(True) End If _ActiveOrder = DirectCast(e.NewSelections(0).Tag, SCE.SCEInterfaces.IOrder) _selectedItem = Nothing prevNode = e.NewSelections(0) Else _ActiveOrder = DirectCast(e.NewSelections(0).Parent.Tag, SCE.SCEInterfaces.IOrder) _selectedItem = DirectCast(e.NewSelections(0).Tag, SCE.SCEInterfaces.IOrderItem) prevNode = e.NewSelections(0).Parent End If End If
End Sub
Hello Nick,
Could you please try to attach if possible a small sample project reproducing the above mentioned issue, I will be happy to take a look at it.
here it is
I try to reproduce your issue using your sample and the same assemblies version, but without success. I made more then 30 tests to reproduce this issue.
Please provide us more details how to reproduce this issue. What is your enviroment ?
Regards
I was trying to get error fixed .. there were no DoEvents originally.
Its not a cause, and it fails without it
Hi,
I tried your sample, as well, and I am also unable to reproduce the issue. But one thing I noticed is that you are using Application.DoEvents() in your code. Why are you using DoEvents?
This is a dangerous thing to do and even Microsoft's documentation recommends that you do not use DoEvents unless you absolutely have to. My guess is that the DoEvents call you have here is causing a timing or re-entrancy issue and that's why the problem is so hard to reproduce. Try taking out the DoEvents and see if you can still get the exception to occur.
This is still not resolved, and if possible I would like to get someone from support to remote to my machine to troubleshoot it.
I need this resolved .. i have multiple clients complaining .. please assist
if the program I provided earlier works for you, please email me xishnik19 .. at .. yahoo.com, so we can schedule the time for you to remote to my machine