I'm trying to add a child node to a parent node in a treeview. I'm finding the loan name by specific key loanresult.LoanName
to the node text. Both show as "TestOne" however the child is not being added to the parent tree node.
Matches then throws the error matches[0].Nodes = 'matches[0].Nodes' threw an exception of type 'System.IndexOutOfRangeException'
due to no matches being found.
foreach (string st in activityList)
{
var activityResult = JsonConvert.DeserializeObject<Activity>(st);
if (loanResult.LoanName == activityResult.ParentLoanName)
{
TreeNode[] matches = tvTodoList.Nodes.Find(loanResult.LoanName, false);
if (matches.Length > 0) matches[0].Nodes.Add(activityResult.ActivityName);
}
}
Text
Key
I must be missing something obvious here?