Detect position in control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top