Hi,
I'm trying to track the cursor position in an UltraTextEditor. Reading the SelectionStart property works but I want to update my postion label when the mouse is clicked in the editor and when the arrow keys (left, right) are pressed.
I tried the MouseClick event but it never occurs and MouseDown only occurs once.
For the keys I used the KeyPress event but it didn't come up for the arrow keys (only for characters, numbers, ...). Trying the KeyDown event works but the position is not correct.
Here is what I have now:
Private Sub TxtTblContent_KeyDown(...) Handles TxtTblContent.KeyDown
If (e.KeyCode = Keys.Right) OrElse (e.KeyCode = Keys.Left) Then
LblCursorPosition.Text = TxtTblContent.SelectionStart
End If
End Sub
Private Sub TxtTblContent_MouseDown(...) Handles TxtTblContent.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
And what I tried:
Private Sub TxtTblContent_KeyPress(...) Handles TxtTblContent.KeyPress
If (e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Right)) OrElse (e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Left)) Then
The MouseClick event was implemented like the MouseDown event.
Any suggestions?
Thanks,
KurtJulius
OK, I'll do my best. :)
Thanks
UltraTextEditor uses a TextBox control when it is in edit mode. The TextBox class does not expose any events that fire when the text selection changes. The only way I can think of to receive a notification in realtime when the text selection is to implement IMessageFilter on the Application and handle the EM_SETSEL windows message for the UltraTextEditor's TextBox. You can get a reference to the TextBox by handling UltraTextEditor's ControlAdded event.