I have a treeview which has a list of users.
After the user edits some information about that user and presses save i repopulate the treeview.
I would like to get back to the user that was being edited.
However when i try and use the below to achieve this it doesnt work.
TreeNode currentNode = this.treeView1.selectedNode;
// Here i repopulate the treeview.
gotoLastLocation(currentNode);
private void gotoLastLocation(TreeNode tn)
{
this.treeView1.SelectedNode = tn;
}
This however doesnt work. Nothing happens to the TreeView. Nothing expands.
If i check the tn.FullPath property i get the following:
System.InvalidOperationException: Full path can only be retrieved when a TreeNode has been added to a TreeView. This TreeNode has not been added to a TreeView.
EDIT: If i check the currentNode.FullPath before repopulating the treeview it works fine. If i check it after repopulating the list it gives the above error.
I cant seem to figure this out. Any ideas?