I have a flexgrid setup to where the user inputs a string until they have the keypress of { when they type in { a dialog box appears having them select a 7 character string. This 7 character string is then inserted into the string at the position of the textbox SelectionStart and saved back to the editor for further editing. Once this is done however the position of the cursor in the edit box goes back to the beginning of the string. I want the cursor to now appear after the 7th character of the inserted value. Example:
I have the string:
The quick brown jumps over the lazy dog
The user edits the cell and types in the following:
The quick brown { jumps over the lazy dog
The { opens a dialog box for the user to choose an animal. The user chooses Fox
The quick brown fox jumps over the lazy dog
but now the edit cursor is in front of the T in The. I want the cursor to be after x in Fox. How do I move that cursor in the editor. Here is a sample of code I have.
Private Sub fg_KeyPressEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.KeyPressEditEventArgs) Handles fg.KeyPressEdit
Dim tb As TextBox
If Not IsNothing(fg.Editor) Then
Try
tb = fg.Editor
Catch ex As Exception
Exit Sub
End Try
If Len(tb.SelectedText) > 1 Then
fgSelectedTxtIndex = tb.SelectionStart
End If
End If
If e.KeyChar = "{" Then
Dim frm As New frmChooser
Dim strModifed As String
frm.ShowDialog()
strModifed = fg.Editor.Text
strModifed = strModifed.Insert(tb.SelectionStart, strChoosenString)
fg.Editor.Text = strModifed
'Removes Initial Key Stroke
e.Handled = True
End If
'TODO: Insert Code to Move Cursor in Editor
end sub
Any Help would be greatly appreciated.
Thanks,