精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
The code to show current caret pos is
stLabEditor1.Text = string.Format("L:{0}, C:{1}", txtSql.ActiveTextAreaControl.Caret.Line + 1, txtSql.ActiveTextAreaControl.Caret.Column + 1);
显示当前光标位置的代码是
stLabEditor1.Text = string.Format("L:{0}, C:{1}", txtSql.ActiveTextAreaControl.Caret.Line + 1, txtSql.ActiveTextAreaControl.Caret.Column + 1);
But the problem is - on which event should I put a call of this code?! That is really the big question.
I have tried lot of events but all of them do not work as expected.
It seems KeyDown/KeyPress/KeyUp and MouseDown/MouseUp events does not work at all for this control.
但问题是——应该在哪个事件里把这段代码调用? !这是真正的大问题。我尝试过很多事件,但它们不像预期的那样工作。
似乎KeyDown /KeyPress/KeyUp 和MouseDown / MouseUp事件不受控制。
So, I set handlers for most of events and put breakpoints in all handlers. There were no calls at all! Only "TextChanged" called a handler, but there were no calls to keyboard and mouse events.
所以,我设置事件处理程序的大部分时间里,把断点设置在所有处理程序。没有调用!只有“TextChanged”调用了一个处理方法,但没有键盘和鼠标事件和调用。
I do not want to use timer to display caret pos. I think that is silly to use timer for such things. I would like to use some event from this control.
我不想使用计时器显示插入符号pos。我认为这是一个笨的方法。我想用一些事件的控制。
Could you please advise something on it?请问你有什么建议么?
Have you tried subscribing to TextArea.Caret.PositionChanged 你尝试订阅TextArea.Caret.PositionChanged吗?
Aha. I thought it should be available in design-time, so I missed it.
Thank you for hint. It works fine now.
哦。我认为这应该只是在设计状态里才能用,所以我把它给忘了。谢谢你的提示。现在工作正常。