* UITextBox: 支持自定义右键菜单
This commit is contained in:
parent
41efc21b4e
commit
9a843d35aa
@ -603,5 +603,21 @@ namespace Sunny.UI
|
||||
DragCtrlsMouseDown.TryRemove(ctrl.Name, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearEvents(object instance)
|
||||
{
|
||||
var events = instance.GetType().GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
|
||||
foreach (var eventInfo in events)
|
||||
{
|
||||
var fieldInfo = instance.GetType().GetField(eventInfo.Name, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
|
||||
if (fieldInfo.GetValue(instance) is Delegate eventHandler)
|
||||
{
|
||||
foreach (var invocatedDelegate in eventHandler.GetInvocationList())
|
||||
{
|
||||
eventInfo.GetRemoveMethod(fieldInfo.IsPrivate).Invoke(instance, new object[] { invocatedDelegate });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@
|
||||
* 2022-07-17: V3.2.1 增加SelectionChanged事件
|
||||
* 2022-07-28: V3.2.2 修复了有水印文字时,不响应Click和DoubleClick事件的问题
|
||||
* 2022-09-05: V3.2.3 修复了无水印文字时,光标有时不显示的问题
|
||||
* 2022-09-16: V3.2.4 支持自定义右键菜单
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -138,6 +139,12 @@ namespace Sunny.UI
|
||||
toolTip.SetToolTip(btn, tipText);
|
||||
}
|
||||
|
||||
protected override void OnContextMenuStripChanged(EventArgs e)
|
||||
{
|
||||
base.OnContextMenuStripChanged(e);
|
||||
edit.ContextMenuStrip = ContextMenuStrip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user