Results 1 to 8 of 8

Thread: Ownerdraw Treeview/Listview

  1. #1

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Ownerdraw Treeview/Listview

    Hi all.

    Does any one have an example of an ownerdrawn treeview and/or listview?
    Combo's and listboxes are no problem, but for some reason MS decided that we don't need that on treeviews and listviews.

    But I hate the ImageList , especially if my nodes and items are dynamic. Even more so, if it's a filelist, so images are created at runtime. It's a drag to add them to the imagelist, and set the imageindex of the item all the time.
    Also, when removing nodes and items, you need to clean up the imagelist to reduce memoryconsumption.

    So I would appreciate it if anyone could guide me in the right direction.

    PS. I have read a little about Custom Draw on MSDN, but it was some Windows SDK that I didn't get. Too much API.

    Thanks.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    What do you mean by:
    Combo's and listboxes are no problem, but for some reason MS decided that we don't need that on treeviews and listviews.
    There are definitely TreeView and ListView controls in .NET, I use them frequently.
    Attached Images Attached Images  

  3. #3

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Originally posted by CyberHawke
    There are definitely TreeView and ListView controls in .NET, I use them frequently.
    I know that. I use them too. I was talking about the possibility for ownerdrawing them.
    Combos and listboxes has a DrawMode property and DrawItem events, that allow me to render them my way.

    Listviews and treeviews don't.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  4. #4
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Sorry, my bad, I thought you meant that they weren't there. What you are looking for is to redraw them with colors borders etc. of your own design?

  5. #5

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Yes, that's exactly what I'm looking for.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  6. #6
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    I've searched and there does not appear to be a paint method associated with these controls, so as far as I can tell, the answer to your question is no. Perhaps you can create a custom control that inherits this one but allows you to paint it. I would start there if I wanted to control the drawing of the control.

  7. #7

    Thread Starter
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I allready tried to inherit both from the Treeview itself but also the treenode.

    And none of them have the methods needed. The treeview does have a OnPaint, but that's the entire control, and there's no way to see which node is being painted.

    I guess I have to subclass the control and catch the messages, but I have no idea where to begin on such an operation.
    I just hoped that somebody else had done it before me, and were willing to share.

    But thanks for trying anyway.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  8. #8
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Problem Sorted?

    Hi there,

    I have the same problem, did you ever work out how to do it?

    Thanks

    Rohan

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