diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 04843ece..cc1608aa 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -32,6 +32,7 @@ * 2023-10-26: V3.5.1 字体图标增加旋转角度参数SymbolRotate * 2023-12-18: V3.6.2 修复高度不随字体改变 * 2024-01-19: V3.6.3 下拉按钮可修改大小及位置 + * 2024-01-27: V3.6.3 修改按钮大小调整时,清除按钮的位置 ******************************************************************************/ using System; @@ -75,8 +76,6 @@ namespace Sunny.UI fillColor = Color.White; edit.BackColor = Color.White; MouseMove += UIDropControl_MouseMove; - - ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height); } int lastEditHeight = -1; @@ -426,7 +425,6 @@ namespace Sunny.UI edit.Left = 4 + Padding.Left; edit.Width = Width - Padding.Left - Padding.Right - 4; - ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height); } /// @@ -481,7 +479,7 @@ namespace Sunny.UI return; } - bool inControlBox = e.Location.InRect(ControlBoxRect); + bool inControlBox = e.Location.X > Width - Padding.Right; if (inControlBox != NeedDrawClearButton && Text.IsValid()) { NeedDrawClearButton = inControlBox; @@ -499,7 +497,6 @@ namespace Sunny.UI } } - Rectangle ControlBoxRect; protected bool showClearButton; protected override void OnGotFocus(EventArgs e) diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index c25cf73c..a6b17809 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -39,6 +39,7 @@ * 2023-07-03: V3.3.9 修改了几个对象的释放 * 2023-08-11: V3.4.1 Items.Clear后,DropDownStyle为DropDown时,不清空Text * 2023-12-26: V3.6.2 增加下拉界面的滚动条设置 + * 2024-01-27: V3.6.3 修复在窗体构造函数设置SelectedIndex报错 ******************************************************************************/ using System; diff --git a/SunnyUI/Controls/UIListBox.cs b/SunnyUI/Controls/UIListBox.cs index 143e8209..d14accae 100644 --- a/SunnyUI/Controls/UIListBox.cs +++ b/SunnyUI/Controls/UIListBox.cs @@ -616,9 +616,21 @@ namespace Sunny.UI public int SelectedIndex { get => listbox.SelectedIndex; - set => listbox.SelectedIndex = value; + set + { + if (value >= 0) + { + if (listbox != null && listbox.Items != null && listbox.Items.ContainsIndex(value)) + listbox.SelectedIndex = value; + } + else + { + listbox.SelectedIndex = value; + } + } } + [Browsable(false)] [DefaultValue(null)] public object SelectedItem