April 3rd, 2013

How can I move an HTREEITEM to a new parent?

Suppose you have a TreeView control, and you created an item in it, and you want to move the HTREEITEM to a new parent. How do you do that?

You can’t, at least not all in one motion.

You will have to delete the HTREEITEM and then re-create it in its new location.

If you want to move an HTREEITEM within the same parent (say, to reorder it among its siblings), then you can use Tree­View_Sort­Children­CB and pass a custom sort function that rearranges the children into the order you want.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.