Maybe I am doing something wrong here. I am using a treeview control , which I populate with data. The data (integers mainly) are transformed to CStrings for that matter. When the user clicks on an item, I can read the CString, but then have to parse it in order to get the data .
Several times I have changed the way the data appears on the screen ,and then everything breaks, and I need to rewrite the parsing function. I wonder if there is a better way to do this…
EDIT : The treeview is being populated with items from a std::vector. If I could get the treeview to return an index in the vector instead of a CString , this would fit me perfectly.
You can use
CTreeCtrl::SetItemDatato associate an arbitrary data value with a tree item, andCTreeCtrl::GetItemDatato retrieve this value. Typically you useSetItemDatato store a pointer to an object, but in your case you could use this to store the integer values directly.I hope this helps!