* UITabControl: 增加DisposeTabPageAfterRemove标志,移除TabPage后,是否自动销毁TabPage

This commit is contained in:
Sunny 2021-08-14 13:48:31 +08:00
parent da7b58168c
commit d5e8d75a19
6 changed files with 14 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -569,6 +569,13 @@ namespace Sunny.UI
get; set; get; set;
} }
[DefaultValue(false)]
[Description("移除TabPage后是否自动销毁TabPage"), Category("SunnyUI")]
public bool DisposeTabPageAfterRemove
{
get; set;
}
internal void RemoveTabPage(int index) internal void RemoveTabPage(int index)
{ {
if (index < 0 || index >= TabCount) if (index < 0 || index >= TabCount)
@ -591,11 +598,14 @@ namespace Sunny.UI
TabPages.Remove(tabPage); TabPages.Remove(tabPage);
AfterRemoveTabPage?.Invoke(this, index); AfterRemoveTabPage?.Invoke(this, index);
tabPage.Dispose();
if (TabCount == 0) return; if (TabCount > 0)
if (index == 0) SelectedIndex = 0; {
if (index > 0) SelectedIndex = index - 1; if (index == 0) SelectedIndex = 0;
if (index > 0) SelectedIndex = index - 1;
}
if (DisposeTabPageAfterRemove) tabPage.Dispose();
} }
public enum UITabPosition public enum UITabPosition