MDI Children Refresh?

MDI Children Refresh?

Old forum URL: forums.lhotka.net/forums/t/955.aspx


CSLAer posted on Saturday, August 19, 2006

Hi,

I have a MDI application. I load a MDI child form with a read-only collection. I jump to another MDI child form to edit the record which is listed in the first form. When I save and close the record edit form. How do I notify the first from to refresh & get updated data? Some sample code will be appreciated.

Thanks

RockfordLhotka replied on Sunday, August 20, 2006

This has been discussed before - search for "observer pattern" and I think you'll find the thead(s). That is ultimately your answer - is to use an observer pattern or a publish/subscribe scheme (which are closely related to each other) to handle the notification scheme.

It is not unlike what I did in the book with the Roles and RoleList classes.

CSLAer replied on Monday, August 21, 2006

Yeah, I can find the posts about Observer pattern. It look too complicated. I'm new to C# & CSLA. Is there any simple way (using event & delegate) to do that?

Vaxman2 replied on Monday, August 21, 2006

The way I handled this was to create an Editable object in the MDI form that had the collection, create the edit form which had a property object for the item to be edited, pass the object to the form, then show the form in a modal mode. When the form was closed, I returned whether the change was applied (OK button) or canceled.

If the change was applied, I would call the editable objects save function and update the collection appropriately.. 

 

malloc1024 replied on Monday, August 21, 2006

Since you are only notifying one object, an observer would be overkillYou really only need a simple callback in this situation.  You can do this with interfaces, events or delegates.   I typically prefer using interfaces for callbacks. 

CSLAer replied on Monday, August 21, 2006

I'm really new to C#. Could you please post few lines of sample codes? thanks

Copyright (c) Marimer LLC