Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorabrevet-dev <57099550+abrevet-dev@users.noreply.github.com>2019-12-04 13:49:43 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2019-12-04 13:49:43 +0300
commita79c4d11a4ce69c6a79ff21778bf308809d36988 (patch)
treea883040d446b4d64bdcb431ee3ba4555824feeb5 /mcs
parent91d3d63858550f38a10851d4ea45d656178947aa (diff)
[WinForms] Editing the DialogResult of the form in the button click event was ignored. (#18025)
Fixes #12022
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Button.cs14
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs2
2 files changed, 10 insertions, 6 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Button.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Button.cs
index 829c55012f0..fee7fb5d799 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Button.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Button.cs
@@ -92,14 +92,16 @@ namespace System.Windows.Forms {
#region Protected Methods
protected override void OnClick (EventArgs e)
{
- if (dialog_result != DialogResult.None) {
- Form p = FindForm ();
-
- if (p != null)
+ Form p = FindForm ();
+ if (p != null) {
+ p.dialog_result_changed = false; // manages the case where the DialogResult of the form is overriden in the button click event.
+ base.OnClick (e);
+ if (dialog_result != DialogResult.None && !p.dialog_result_changed) {
p.DialogResult = dialog_result;
+ }
+ } else {
+ base.OnClick (e);
}
-
- base.OnClick (e);
}
protected override void OnFontChanged (EventArgs e)
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
index 329736ffb81..73dff86a6a7 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
@@ -102,6 +102,7 @@ namespace System.Windows.Forms {
private bool autoscale_base_size_set;
internal ArrayList disabled_by_showdialog = new ArrayList();
internal static ArrayList modal_dialogs = new ArrayList();
+ internal bool dialog_result_changed;
#endregion // Local Variables
#region Private & Internal Methods
@@ -637,6 +638,7 @@ namespace System.Windows.Forms {
typeof (DialogResult));
dialog_result = value;
+ dialog_result_changed = true;
if (dialog_result != DialogResult.None && is_modal)
RaiseCloseEvents (false, false); // .Net doesn't send WM_CLOSE here.
}