Hi All I have developed a custom user control for onscreen Keyboard functionality. When user clicks any button then it should act accordingly and add the appropriate character into the string or do the appropriate action(Delete, Backspace etc). Now if user sets cursor in the middle of the string in textbox and then clicks keyboards button for example 'a' then how to find the index where cursor exist in the textbox and add 'a' to that perticullar location. At the moment I am adding every character on the last index of the string but this is not appropriate. Any hint or any solution which can help me get going will be highly appreciated. Thanks In Advance Regards Fiaz Ali Saleemi
If you know that SelectionLength is 0 you can simply use SelectionStart However, if SelectionLength is not 0, the caret can be at either end of the selection, meaning SelectionStart is of no use to you. In that case you'll need to use P/Invoke and call GetCaretPos and then issue a EM_CHARFROMPOS message to the textbox Another approach is to put your character on the clipboard and the call the Paste method. That would put it at the correct location automatically. You might want to save the old clipboard content first so you can restore it afterwards. /claes "Fiaz Ali Saleemi" wrote in message news:esVXvY6ZGHA.3496@TK2MSFTNGP05.phx.gbl... > Hi All > > I have developed a custom user control for onscreen Keyboard > functionality. > When user clicks any button then it should act accordingly and add the > appropriate character into the string or do the appropriate action(Delete, > Backspace etc). > Now if user sets cursor in the middle of the string in textbox and then > clicks > keyboards button for example 'a' then how to find the index where cursor > exist in the textbox and add 'a' to that perticullar location. At the > moment > I am adding every character on the last index of the string but this is > not > appropriate. > Any hint or any solution which can help me get going will be highly > appreciated. > > > Thanks In Advance > > > Regards > Fiaz Ali Saleemi > >