A
A
Alexey2011-06-28 19:07:44
Windows Forms
Alexey, 2011-06-28 19:07:44

[email protected] pattern: how to understand in View whether there have been changes in the data?

Given: A C# WinForms application that tries to follow the MVP pattern.
View is a form with a grid, there is data in the grid. There are also buttons that do something with this data. View doesn't know what. It simply generates events on button clicks that are handled by the presenter.
Task: when closing the form, it is necessary to understand whether there were changes in the data, and if there were, then ask whether to save them.
Options that come to mind (but none of them like it):
1. By pressing the buttons, conclude that the data has changed.
2. Ask about saving from the presenter.
3. Generate an event like “have there been any changes?”, but there are no reasonable ideas about the arguments and the name of this event.
Please advise how to resolve the situation.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kefirr, 2011-06-28
@kefirr

Displaying the dialog is the responsibility of the View. Whether there were changes in the data - the Presenter knows.
That is, in the form close event, the View must call some Presenter method to find out if there have been changes, then show the dialog if there have been.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question