How to correctly synchronize updates between forms?

Posted on 2006-06-29
Last Modified: 2010-04-16
I have a Windows application with a MainForm that has a menue and a DataGridView with two columns on it. The first column is read-only and contains Roles the current Windows user can have. The second column contains a CheckBox indicating whether the current Windows user actively participates in the Role or not. The user can edit this CheckBox.

The idea is to provide a tool for testers that allows them to switch roles for testing in a easy and fast manner by just check marking the roles they need. So far any thing works fine and as expected.

The MainForm provides a menue to let developers and administrators access forms, opend as dialogs, for further role managment and assignment. This is where the problem starts.

As an example I take the situation where a developer clicks on the menue to "Assign Roles to Users". In this case a Form is opened as a dialog. The Form contains a DataGridView similar to that on the MainForm but showing all users data and therefore having one more column with the Username.

Now the problem is, that if I mark/unmark the active flag for a role on the MainForm before opening the "Assign Roles to Users" form, that change is not contained in the data after opening the "Assign Roles to Users" form.

The DataGridViews on the two forms are based on the same DataSet and TableAdapter. However, they differ in the query. The difference in the queries is the WHERE clause (WHERE UserID = @CurrentUser).

The main problem I see is that the data do not get updated before the user actively switches the row. If the user switches the row before opening the other form, I can get the updates from the MainForm to the assignment form.

How can I get the updates and properly synchronize them between forms?

The following links includes screenshots.
1. MainForm after application has been started

2. Select Manager role

3. Open the form for further Role to User assignment

4. After the form has been opened, the value previousely changed in MainForm is not there

You might also take a look at my previous question releted to the same issue:
Question by:pgloor
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 13

Assisted Solution

devsolns earned 250 total points
ID: 17009127
Model-View-Controller MVC design pattern.
LVL 12

Assisted Solution

topdog770 earned 250 total points
ID: 17009833
To further expound on devsolns comment..

The idea is to make your data..( the model ) separate from your user interface( the view ) so that when you switch from form to form and make changes ( routed through the controller ) all of the forms 'see' the same information.


Author Comment

ID: 17010067
@devsolns: Actually I already thought about MVC with an observer as an option.

However, Microsoft provides such nice tools to reduce development time and get things done faster than ever, so I almost can't believe it can't be done with what they have given to us.

@topdog779: I appreciate your answer. However, I know the basics of the MVC pattern.

Has any of you implemented the MVC pattern in a .NET application?
If yes, then I'm interested in the architecture f your implementation.

I'm also interested in thoughts about the extra effort needed.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 12

Accepted Solution

topdog770 earned 250 total points
ID: 17010142
lol... sorry..

I typically cheat.. for smaller projects where I want to share common data, I'll create a singleton class that maintains the data and then have the GUI components read and write to the singleton class.

I then put as much of the logic into the singleton class as I can easily do, with the remaining logic being handled in the GUI.

I agree with you that we have these great tools for quick development, and not as much built-in support for patterns, and the MVC pattern can easily become cumbersome ( imho )


Author Comment

ID: 17018140
Ok, after spending a couple of hours implementing MVC I'm on the right track towards a working solution that solves the actual problem but raises several new questions.

Even its implementation differs from mine, taking a closer look at the standard .NET implementation I can clearly see the MVC pattern as well. Isn't the DataSet the Model, the BindingManager the Controller and the DataGridView the View?
LVL 13

Expert Comment

ID: 17018237
LVL 12

Expert Comment

ID: 17018250
Implementing 'official' patterns is still very new to me.. although, we've pretty much been using the principles for years.

I think that's the key with patterns, though--using the pattern to help complete (our) designs and programs and not work so hard at making (our) ideas fit into a specific pattern!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
need to convert function to c# 5 55
c# ftp code 3 56
Disable the weekends on datepicker control 6 52
How to send the email using C# with embedded HTML TABLE 3 19
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question