Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3555
Architecture Question...
posted

Ok here is the deal, we allow multiple forms to be opened at once.  If a user deletes an entity in one form that is being used by another form we have to refresh the other form.  Now since there are about 15 forms in our application and all 15 can be opened at once you can then imagine the matrix of refreshes we need to do.  

My question is this..  Is there a way or a framework out there that can handle autofreshing other forms.

 

For example.  If we have a customers table in memory and form1/grid is binded to a linq query off of that table and  then we have form2/grid binded to a linq query off of that table as well (but a different subset), and then I update grid1, thus updating the customers table object, and if I did that an auto notification would get sent out to all queries that are joined to that table?Or do I really have to keep this matrix of what to refresh? 

The problem is my app is very similiar to having multiple related worksheets in an excel workbook, but I am not going to relate grids because they can close any form at anytime.  This is what our users want, and it is annoying as hell.

 

Any help would be grealty appreciated.

Parents
  • 45049
    posted

    Are you using Windows Forms data binding to populate the information in yoru forms?  If so, you can probably use the binding manager to do this work for you.

    To do this, all of the controls that you want to be refreshed automatically based on changes to each other must share the same binding context.  Generally, a control shares the binding context of its form, and each form has its own binding context.  You can make multiple forms share a single binding context by setting the BindingContext of one to match the one on an existing form.  This is generally best done when the new form is opened.

    For instance, I have two Form classes.  Form1 is the root form of my application, and I show Form2 as a separate child form.  The following C# code gives me a new instance of Form2 and makes it share the binding context of Form1 ("this" in the below example):

    Form2 newForm = new Form2();
    newForm.BindingContext = this.BindingContext;
    newForm.Show();

    Now, whenever I update a control on my new Form2 instance, any databound controls bound to the same data source will be updated on Form1, as if all the controls were on the same form. 

    You can likely find more resources describing this approach on MSDN.

Reply Children