Detect position in control

D

Daniel

Hello,

Is there a way to detect where the user has the cursor positioned within a
control text?

Let say I have a memo control with the text "Hello my name is and I'm 22
yrs old." and the user places their cursor between the 'is' and the 'and',
can this be detected in some way so that I split the control content to make
changes at the curcor point.

Secondly, obviously I cannot use a button to initiate my code to make an
edit to the text (the cursor would no longer be valid) is the a way to
execute code from a keyboard (for instance ctrl+shift+e would initiate some
code)?

Thank you,

Daniel
 
D

Douglas J. Steele

Take a look at the SelStart property of the text box. (Note that you can
only address this, and the related SelWidth and SelText properties, when the
text box has focus)

And yes, you can use a button. You could keep track of what SelStart was
before the text box lost focus (use the text box's LostFocus event), and go
from there.
 
D

Daniel

Thank you Douglas!




Douglas J. Steele said:
Take a look at the SelStart property of the text box. (Note that you can
only address this, and the related SelWidth and SelText properties, when the
text box has focus)

And yes, you can use a button. You could keep track of what SelStart was
before the text box lost focus (use the text box's LostFocus event), and go
from there.
 
Top