I think you have to recurse through the control items from your root point, get the item data and do the comparison - similar to how this does.
MFC CTreectrl - find item by data
Hi,
In MFC CTreeCtrl, I inserted items and set item data using SetItemData().
Now I want to search CTreeCtrl items by data which I set using SetItemData().How to do it?
Thanks.
1 additional answer
Sort by: Most helpful
-
Sheng Jiang 蒋晟 206 Reputation points
2020-11-30T14:23:01.953+00:00 you can create index on your data source that you want search with. then create a searchable data structure between HTREEITEM and your index value and look up by value later.
e.g. if you want to do exact search based on an int field in your data source, when you add tree items and got HTREEITEM, add a new pair of <int, HTREEITEM> to a std::hashmap<int, HTREEITEM> object, then you can look up HTREEITEM by the int field value. if you want to do a greater then search based on the field, you can consider a self balancing BST. If you have multiple field to index, consider Boost's Multi-index containers.