I have a virtual tree view that I want to uncheck the n-th checked box. So, I created a sample project just to uncheck the first one and the only option I can see working is something like maintaining an external vector of the checked status of each node. Is there any chance of something like the following working?
void __fastcall TForm1::btnClearFirstIconClick(TObject *Sender)
{
int NullsFound = 0;
TAdvTreeViewVirtualNode *ANode = AdvTreeView1->GetFirstRootVirtualNode();
TAdvTreeViewNode *aNode;
while (ANode) {
aNode = ANode->Node; // Always returns NULL
if (aNode) {
if (aNode->Checked[0]) {
AdvTreeView1->BeginUpdate();
aNode->Checked[0] = false;
AdvTreeView1->EndUpdate();
break;
}
} else {
NullsFound ++;
}
ANode = AdvTreeView1->GetNextVirtualNode(ANode);
}
if (NullsFound) {
ShowMessage(UnicodeString(NullsFound) + L" Nulls found");
}
}
If the above is executed in a tree with 9 nodes, the message displayed will be "9 Nulls found", so I know it is correctly traversing the tree.