* UITabControl: 修复了SelectedIndex=-1时的报错
This commit is contained in:
parent
f831a92cf7
commit
98d280d9f0
@ -33,9 +33,9 @@
|
|||||||
* 2023-05-12: V3.3.6 重构DrawString函数
|
* 2023-05-12: V3.3.6 重构DrawString函数
|
||||||
* 2023-11-06: V3.5.2 重构主题
|
* 2023-11-06: V3.5.2 重构主题
|
||||||
* 2023-12-13: V3.6.2 优化UIPage的Init和Final加载逻辑
|
* 2023-12-13: V3.6.2 优化UIPage的Init和Final加载逻辑
|
||||||
|
* 2024-11-29: V3.8.0 修复了SelectedIndex=-1时的报错
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using Sunny.UI.Win32;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -43,6 +43,7 @@ using System.ComponentModel;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Sunny.UI.Win32;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (pageIndex < 0) return false;
|
if (pageIndex < 0) return false;
|
||||||
|
|
||||||
if (PageItems.TryGetValue(tabControl.SelectedTab, out var fromPage))
|
if (tabControl.SelectedTab != null && PageItems.TryGetValue(tabControl.SelectedTab, out var fromPage))
|
||||||
{
|
{
|
||||||
bool isCancel = fromPage.OnPageDeselecting();
|
bool isCancel = fromPage.OnPageDeselecting();
|
||||||
if (isCancel) return false;
|
if (isCancel) return false;
|
||||||
@ -122,7 +122,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (pageGuid == Guid.Empty) return false;
|
if (pageGuid == Guid.Empty) return false;
|
||||||
|
|
||||||
if (PageItems.TryGetValue(tabControl.SelectedTab, out var fromPage))
|
if (tabControl.SelectedTab != null && PageItems.TryGetValue(tabControl.SelectedTab, out var fromPage))
|
||||||
{
|
{
|
||||||
bool isCancel = fromPage.OnPageDeselecting();
|
bool isCancel = fromPage.OnPageDeselecting();
|
||||||
if (isCancel) return false;
|
if (isCancel) return false;
|
||||||
@ -142,7 +142,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public UIPage GetPage(TabPage tabPage)
|
public UIPage GetPage(TabPage tabPage)
|
||||||
{
|
{
|
||||||
if (PageItems.TryGetValue(tabControl.SelectedTab, out var uiPage))
|
if (tabControl.SelectedTab != null && PageItems.TryGetValue(tabControl.SelectedTab, out var uiPage))
|
||||||
return uiPage;
|
return uiPage;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user