diff --git a/SunnyUI/Forms/UIEditForm.cs b/SunnyUI/Forms/UIEditForm.cs index f040c3e8..2e9fa153 100644 --- a/SunnyUI/Forms/UIEditForm.cs +++ b/SunnyUI/Forms/UIEditForm.cs @@ -21,6 +21,7 @@ * 2021-05-19: V3.0.3 动态生成表单,增加校验方法 * 2021-10-26: V3.0.8 代码生成增加ComboTreeView类型 * 2021-10-28: V3.0.8 代码生成增加ComboCheckedListBox类型 + * 2022-04-18: V3.1.5 修改一处Show引起的无法获取控件值的问题 ******************************************************************************/ using System; @@ -294,31 +295,39 @@ namespace Sunny.UI set => btnCancel.Enabled = value; } - protected void btnOK_Click(object sender, EventArgs e) + private void btnOK_Click(object sender, EventArgs e) { if (!CheckData()) { return; } + else + { + DialogResult = DialogResult.OK; + IsOK = true; + } if (CheckedData != null) { if (!CheckedData.Invoke(this, new EditFormEventArgs(this))) { + DialogResult = DialogResult.None; + IsOK = false; return; } + else + { + DialogResult = DialogResult.OK; + IsOK = true; + } } if (ButtonOkClick != null) { + DialogResult = DialogResult.None; + IsOK = false; ButtonOkClick.Invoke(sender, e); } - else - { - DialogResult = DialogResult.OK; - IsOK = true; - Close(); - } } private void btnCancel_Click(object sender, EventArgs e) diff --git a/SunnyUI/Forms/UIInputForm.cs b/SunnyUI/Forms/UIInputForm.cs index d24e47cd..07ebac89 100644 --- a/SunnyUI/Forms/UIInputForm.cs +++ b/SunnyUI/Forms/UIInputForm.cs @@ -60,8 +60,7 @@ namespace Sunny.UI protected override void DoEnter() { if (btnCancel.Focused || btnOK.Focused) return; - - btnOK_Click(null, null); + btnOK.PerformClick(); } private void UIInputForm_Shown(object sender, System.EventArgs e)