Results 1 to 6 of 6

Thread: Easy Treeview Modification

  1. #1

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Easy Treeview Modification

    Is there an easy way to modify the nodes in the treeview so that it can display a panel or some other control as part of one of the nodes? (See attached picture)
    Attached Images Attached Images  

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Easy Treeview Modification

    It depends what you mean by easy. You'd have to set the DrawMode to something other than Normal and handle the DrawNode event. I think that OwnerDrawText should be enough, so that the other elements of the TreeView are still drawn automatically.

  3. #3

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Re: Easy Treeview Modification

    By easy I mean relatively little COM and API. I am still pretty new to .net. I am pretty well versed in both VB6 and Java, so I understand the concepts, I just haven't figured out all the syntax differences and language specific features/quirks of C# yet.

    What you have described sounds simple enough. I will give it a shot. Thanks.

  4. #4

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Re: Easy Treeview Modification

    I have been busy with other stuff and just managed to pick this up again.

    Setting the DrawMode to OwnerDrawText works but does not resize the TreeNode. I have been looking for a way to resize a single TreeNode without resizing all TreeNodes contained in the TreeView. The TreeNode.Bounds property is Read Only, so I can't change it.

    Any ideas of how to change the height of a single TreeNode without affecting all the others?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Easy Treeview Modification

    If OwnerDrawText doesn't give you enough control then you're going to have to use OwnerDrawAll and take responsibility for all drawing. It just means that you will have to draw the other nodes the same way as they would be by default.

  6. #6

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Re: Easy Treeview Modification

    I tried that, but when I drew the node, the box just appeared behind the sub-nodes and nodes underneath. Because of this, I tried to change the height of the node so that the next nodes down would automatically be rendered lower in the list, but I could not find a way to change the TreeNode.Bounds property. It seems that this property is being set by the TreeView control and I can't figure out a way to override it...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width