How can I get the Index of a tree control Item ?
-
I have a tree tree control with check boxes corresponding to the leaf items. How can I retrieve the zero-based index of the leaf item when I click on their corresponding check box. Thanks in advance
You may compute it traversing the childs of the selected item's parent. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I have a tree tree control with check boxes corresponding to the leaf items. How can I retrieve the zero-based index of the leaf item when I click on their corresponding check box. Thanks in advance
I could write the following code snippet based on the suggestion to accomplish the requirement :
HTREEITEM hSelectedItem = m_pwndPageTree->HitTest(&HitTestInfo);
:
:
HTREEITEM hNextItem = m_pwndPageTree->GetRootItem();INT nCounterForPageIndex = 0;
if (hSelectedItem != hNextItem)
{
while (hSelectedItem != hNextItem)
{
hNextItem = m_pwndPageTree->GetNextItem(hNextItem, TVGN_NEXTVISIBLE);
nCounterForPageIndex++;
}
}Thanks for the suggestion