Hi
I am trying to add a custom icon near the text of a TreeNode, so the items could have a "checked/unchecked" state displayed. I don't want to use a checkbox for that.
Any ideas? Thanks
Hi
I am trying to add a custom icon near the text of a TreeNode, so the items could have a "checked/unchecked" state displayed. I don't want to use a checkbox for that.
Any ideas? Thanks
Assuming you are using .net and Windows Forms.
You must set DrawMode property of TreeView to TreeViewDrawMode.OwnerDrawAll. Once you do this, treeview's DrawNode event will fire each time a tree node is being drawn. Handle that event and draw your items manually.
You will get DrawTreeNodeEventArgs as the event arguments. State property of it will tell you which state of the tree item you must draw. e.Bounds will help you for determining bounds and you can use e.Graphics for drawing. You can find more detailed information here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx
But prepare to invest multiple hours.