Answered by:
Customization of TreeNode

Question
-
hi,
i have a treeview with checkboxes, images and text.
i need to change the spacing between the checkbox, image and the node text.
Must i use the DrawNode event and draw the checkbox, image and the text at new positions?
Does someone have a example code for this problem?
thx!
Saturday, May 21, 2011 9:12 PM
Answers
-
Hi Miccza,
Welcome to the MSDN Forum.
According to your description, it seems that you want to put some space among the control.
If I have misunderstood anything, please feel free to let me know.
You can try set some space at the header of the string, e.g, change the "subitem" to " subitem".
There is a sample code about how to use drawnode event:http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx
And there is a sample about treeview with picture:http://www.codeproject.com/KB/tree/TreeWithColumns.aspx
I hope this will be helpful.
If anything is unclear, please feel free to let me know.
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, May 23, 2011 3:16 AM
All replies
-
Hi Miccza,
Welcome to the MSDN Forum.
According to your description, it seems that you want to put some space among the control.
If I have misunderstood anything, please feel free to let me know.
You can try set some space at the header of the string, e.g, change the "subitem" to " subitem".
There is a sample code about how to use drawnode event:http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.drawnode.aspx
And there is a sample about treeview with picture:http://www.codeproject.com/KB/tree/TreeWithColumns.aspx
I hope this will be helpful.
If anything is unclear, please feel free to let me know.
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, May 23, 2011 3:16 AM -
the solution with the DrawNode-Event is too oversized, because i have to redraw the tree-lines, checkboxes, pictures and the text again.
i only need to change the spacing between them.
do you know how to set margin/padding between:
lines and checkbox
checkbox and picture
picture and text
Wednesday, May 25, 2011 6:57 AM -
Hi Miccza,
There is no such kind of margin to set. Please take a look at the code sample, it is not as so diffcult as you image.
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Edited by Mike Feng Wednesday, June 8, 2011 3:43 AM
Thursday, June 2, 2011 9:53 AM -
Hi Miccza,
Thanks for posting in the MSDN Forum.
Any update? I have marked my own reply as answer, if you think it provides no help, please unmark it, and feel free to let me know your any concerns.
Thank you for your understanding and support.
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, June 6, 2011 4:34 AM