* UINumPadTextBox: 增加默认事件ValueChanged,下键盘Enter事件相应此事件

This commit is contained in:
Sunny 2023-03-26 10:34:21 +08:00
parent aada4e651a
commit 59265b4bb1

View File

@ -1,4 +1,26 @@
using System; /******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UINumPadTextBox.cs
* :
* : V3.3
* : 2023-03-18
*
* 2023-03-18: V3.3.3
* 2023-03-26: V3.3.3 ValueChangedEnter事件相应此事件
******************************************************************************/
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
@ -6,6 +28,7 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
[ToolboxItem(true)] [ToolboxItem(true)]
[DefaultEvent("ValueChanged")]
public class UINumPadTextBox : UIDropControl, IToolTip public class UINumPadTextBox : UIDropControl, IToolTip
{ {
public UINumPadTextBox() public UINumPadTextBox()
@ -16,6 +39,8 @@ namespace Sunny.UI
fullControlSelect = true; fullControlSelect = true;
} }
public delegate void OnValueChanged(object sender, string value);
public event OnValueChanged ValueChanged;
private NumPadType numPadType = NumPadType.Text; private NumPadType numPadType = NumPadType.Text;
[DefaultValue(NumPadType.Text)] [DefaultValue(NumPadType.Text)]
@ -125,6 +150,7 @@ namespace Sunny.UI
} }
break; break;
case 13: case 13:
ValueChanged?.Invoke(this, Text);
break; break;
default: default:
Win32.User.PostMessage(edit.Handle, WM_CHAR, (int)value, 0); Win32.User.PostMessage(edit.Handle, WM_CHAR, (int)value, 0);