CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Jul 2006
    Posts
    97

    Updating the TreeView when business object changes

    Hello!

    Once again, I have a question regarding design of the code. Let me explain the situation:

    I have a hierarchical list of business objects, that I want to show in a TreeView. The number of elements and levels can vary, from only a couple to hundreds of objects. It has the following structure:

    Code:
    content list class
     |__content item
     |__content item
     |__content item
     |    |__content item child
     |    |__content item child
     |    .......
     |__content item
     .....
    After populating the TreeView, the list and object properties that it reflects can of course change. I can, of course, re-populate the whole TreeView, but that gets slow. So I want to notify the TreeView about each particular change, so it could process just the node that has changed.

    I'm wondering, what, in your opinion, is the best way to notify the TreeView about list and object changes?

    I'm of course aware, that I can use events in every object and collection I use, but that involves subscribing to hundreds of events. As I examined the TreeView control a little bit more, it has general events, like 'NodeMouseClick', 'NodeMouseHover', etc., that passes the node that caused the event to the delegate.
    So I'm wondering if it is a good way to use single event at the highest level of my object hierarchy to handle events of all the child objects? The best way I can imagine is to create a method that raises the event in the top level collection and call it from the child objects, but it must be a public method then (or internal, but that doesn't change anything, since there are other application layers in the same assembly) so I have a little doubt about this. Should I really expose a method that raises an event to the public?.. I'm confused and haven't found a solution on google yet :/

    I'd be grateful if you could share your experience on this matter
    Last edited by gecka; January 13th, 2009 at 02:35 PM.
    Using .NET 2.0

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

Featured