diff --git a/SunnyUI/Common/UControl.cs b/SunnyUI/Common/UControl.cs index 789b1a00..afc93176 100644 --- a/SunnyUI/Common/UControl.cs +++ b/SunnyUI/Common/UControl.cs @@ -296,6 +296,7 @@ namespace Sunny.UI public static List GetControls(this Control ctrl, bool includeChild = false) where T : Control { List values = new List(); + if (ctrl.IsNull()) return values; foreach (Control obj in ctrl.Controls) { diff --git a/SunnyUI/Frames/UIMainFrame.cs b/SunnyUI/Frames/UIMainFrame.cs index 84eeb7e2..dc0732b4 100644 --- a/SunnyUI/Frames/UIMainFrame.cs +++ b/SunnyUI/Frames/UIMainFrame.cs @@ -18,6 +18,7 @@ * * 2020-05-05: V2.2.5 页面框架基类 * 2021-08-17: V3.0.8 删除IFrame接口,移到父类UIForm + * 2022-05-17: V3.1.9 修复了显示页面关闭按钮,移除最后一个页面出错的问题 ******************************************************************************/ using System; @@ -89,7 +90,7 @@ namespace Sunny.UI private void MainContainer_Selecting(object sender, TabControlCancelEventArgs e) { - if (Selecting != null) + if (Selecting != null && e.TabPage != null) { List pages = e.TabPage.GetControls(); Selecting?.Invoke(this, e, pages.Count == 0 ? null : pages[0]);