I am trapping the right-click event on the editor of an UltraTextboxEditor. I would like to be able to determine the character position in the text where it occurs similar to the Microsoft textbox control method 'GetPositionFromCharIndex'. Is this stored anywhere or can it be derived through code?
Vic,
If the editor is in edit mode (as it will be if you handle the MouseUp event), you can access the TextBox that is used internally and call GetPositionFromCharIndex on that TextBox:
Me.UltraTextEditor1.Editor, EditorWithText).TextBox.GetPositionFromCharIndex(3)
I am curious why you don't just use the coordinates from the mouse event and get them from the textbox based on text location.
Let me know if you have any questions with this matter.
Alan,
Here is the code that will hopefully answer your questions.
Dim editorInfragistics As New Infragistics.Win.EmbeddableTextBoxWithUIPermissions editorInfragistics = CType(sender, Infragistics.Win.EmbeddableTextBoxWithUIPermissions)
Dim m As Integer = 0 Dim n As Integer = MyBase.Text.Length - 1Dim dpt As Point = editorInfragistics.GetPositionFromCharIndex(n) Select Case True
Case e.Location.X = 0
holdStartPos = 0
Case e.Location.X > dpt.X
holdStartPos = MyBase.Text.Length
Case Else
For m = 1 To n
dpt = editorInfragistics.GetPositionFromCharIndex(m) If e.Location.X <= dpt.X Then
holdStartPos = m Exit For
End If
Next
End Select
I knew it had to be in there somewhere and it works the way I want now. Thanks for your timely help!