向 MemoExEdit 控件添加字符计数器
我正在尝试制作一个字符计数器,40/200...41/200等等。现在,对于文本框控件,我用类似的东西挂钩到 KeyUp 事件...
public static void GetRemainingChars(MyTextBox txt, LabelControl lbl)
{
var maxChars = txt.Properties.MaxLength;
lbl.Text = txt.Text.Length + "/" + maxChars;
}
不幸的是,MemoExEdit 控件有一个弹出窗口,您可以在其中键入文本,并且似乎被隐藏。我尝试了KeyUp
、EditValueChanging
、TextChanged
,它们都做了同样的事情。在用户关闭弹出窗口之前它们不会触发。我猜测它是一个复合控件,在关闭时传输编辑值。
关于如何参加弹出窗口活动有什么想法吗?有其他方法可以做到这一点吗?
I am trying to make a character counter, 40/200...41/200 and so on. Now for a textbox control I am hooking into the KeyUp Event with something like this...
public static void GetRemainingChars(MyTextBox txt, LabelControl lbl)
{
var maxChars = txt.Properties.MaxLength;
lbl.Text = txt.Text.Length + "/" + maxChars;
}
Unfortunately the MemoExEdit control has a popup window you type the text into and that seems to be hidden. I tried the KeyUp
, EditValueChanging
, TextChanged
, and they all do the same thing. They don't fire till the user closes the popup. I am guessing that it is a composite control that transfers the editvalue when it closes.
Any ideas on how I can get at the popups events? Is there a different way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是因为我在其他地方找不到这个,所以我会为了其他人的利益发布我的解决方案。
订阅 MemoExEdit 控件的 Popup 事件,然后在其中订阅 EditValueChanging 事件。这就是你可以加入的地方。请参阅下面的我的工作版本。您自己可能需要进行调整。此外,弹出事件是在我的 Designer.cs 文件中创建的。
Just because I couldn't find this anywhere else I will post my solution for other's benefit.
Subscribe to the Popup Event of the MemoExEdit control, then inside that subscribe to the EditValueChanging Event. That is where you can hook in. See below for MY working version. Tweaks may be needed for yourself. Also, the Popup Event is created in my Designer.cs file.