TAdvTreeView FindNodeByTextAndColumn return NULL

Hi, i'm trying to Find a Node on my Tree using FindNodeByTextAndColumn but couldn't find any node.
My C++ code:

TAdvTreeViewNode *pn,*pn2;
pn = Tree->AddNode();
pn->Text[0] = "Something";
pn2 = Tree->FindNodeByTextAndColumn("Something", 0, true, true);

pn2 is always NULL. Any suggestions?

Thanks

When are you executing this code? Can you try wrapping the code with Tree->BeginUpdate(); Tree->EndUpdate(); and then afterwards call Tree->FindNodeByTextAndColumn?

Good morning,
the code was already wrapped between Tree->BeginUpdate() and Tree->EndUpdate(), sorry for didn't mention it, so after your answer i tried to do the opposite: i removed those instructions and now works fine. I don't know if this is intended but thank you for the hint.

Hmm that's strange, EndUpdate triggers node structure recalculation so it should then allow the method to return the value correctly. But the code needs to be like:

TAdvTreeViewNode *pn,*pn2;
Tree->BeginUpdate();
pn = Tree->AddNode();
pn->Text[0] = "Something";
Tree->EndUpdate();
pn2 = Tree->FindNodeByTextAndColumn("Something", 0, true, true);

Modified the code as you suggested. Works well. So the error was that FindNodeByTextAndColumn was inside BeginUpdate() - EndUpdate(), and if i have understood correctly at that time the node structure didn't existed before EndUpdate().

That's correct. When adding nodes, the node structure gets updated. If you don't use BeginUpdate & EndUpdate, then that's fine, but it will affect loading performance when you are adding more and more nodes. Therefore, we bundle all node updates into a single call. Of course, only after EndUpdate is called, the node structure is complete and you can start a search.