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