This was a very helpful link for sorting TreeView Nodes in AfterLabelEdit event. It works great. The only problem is that it changes SelectedNode and TopNode to the Root. How can I get it to be the Node that was originally selected (now with a new text value) AND with TopNode set as it was before sorting?
Here is what my code looks like now:
Private Sub tvInventory_AfterLabelEdit(sender As Object, e As System.Windows.Forms.NodeLabelEditEventArgs) Handles tvInventory.AfterLabelEdit
tvInventory.BeginInvoke(New MethodInvoker(AddressOf tvInventory.Sort))
e.CancelEdit = False
End Sub
I tried adding code to set the tvInventory.SelectedNode and tvInventory.TopNode values inside the AfterLabelEdit event handler but they are just ignored.