Search code examples
c#.netwinformstreeview

Can I add space between nodes in Forms.TreeView?


I want my System.Windows.Forms.TreeView to have spaces between all root nodes.

For example, if they look like this:

A
  B
  C
D
  E
F
  G
  H

I want them spaced apart like this:

A
  B
  C


D
  E


F
  G
  H

Thanks!


Solution

  • You can use the ItemHeight property which sets the height, in pixels, of each tree node in the tree view. But it just sets the spaces for every TreeNode, you cannot give different heights for different TreeNode. There is no easy way to give different ItemHeights for TreeNodes.