"IndexOutOfRange" When trying to access form->treeView1->Nodes->Find array

Viewed 19

I'm trying to find a TreeNode with a certain Name inside my Treeview. For that, I want to use the Find function.

The problem is every time I try to access the Array I get the IndexOutOfRange exception. When debugging, I can see that the index im accessing has a value in it.

if (!form->treeView1->Nodes->Find(gcnew String(primary.c_str()), false))
        {
            std::cout << "NoValue" << std::endl;
        }
        else
        {
            System::Windows::Forms::TreeNode^ prima = form->treeView1->Nodes->Find(gcnew String(primary.c_str()), true)[0];
            prima->Nodes->Add(second);
        }

Here you can see the Debug I did. I put the Breakpoint at the prima variable where the array that the Find function is returning is accessed.

0 Answers
Related