By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

Find the cursor position in a textbox

P: n/a
Could anyone suggest a way in which I could find the position of the cursor
within a textbox.

I want to evaluate every keypress made within the textbox in order to
validate it but in order to do this I need to know where the cursor is when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

TextBox1.MousePosition

Ken
----------------------
"Neil Robbins" <ne**@talent-centre.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Could anyone suggest a way in which I could find the position of the
cursor
within a textbox.

I want to evaluate every keypress made within the textbox in order to
validate it but in order to do this I need to know where the cursor is
when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.

Nov 20 '05 #2

P: n/a
Hi Ken,

Thanks for the response, unfortunately I think that perhaps I should have
been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So
if there are 10 characters allowed in the textbox and the user has entered a
string of 6 characters but has gone back to edit the third character I need
to know that it is the third character that is being edited and not the
second (or any other) character.

I hope that this clarifies things a little.

Any further help would be greatly appreciated.

Neil R.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Oy*************@TK2MSFTNGP10.phx.gbl...
Hi,

TextBox1.MousePosition

Ken
----------------------
"Neil Robbins" <ne**@talent-centre.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Could anyone suggest a way in which I could find the position of the
cursor
within a textbox.

I want to evaluate every keypress made within the textbox in order to
validate it but in order to do this I need to know where the cursor is
when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.


Nov 20 '05 #3

P: n/a
* "Neil Robbins" <ne**@talent-centre.com> scripsit:
Thanks for the response, unfortunately I think that perhaps I should have
been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So
The text cursor is called caret.
if there are 10 characters allowed in the textbox and the user has entered a
string of 6 characters but has gone back to edit the third character I need
to know that it is the third character that is being edited and not the
second (or any other) character.


Maybe you are looking for the control's 'SelectionStart' property?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
Thanks Herfried thats just what I was looking for.

Neil R.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2h************@uni-berlin.de...
* "Neil Robbins" <ne**@talent-centre.com> scripsit:
Thanks for the response, unfortunately I think that perhaps I should have been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So

The text cursor is called caret.
if there are 10 characters allowed in the textbox and the user has

entered a string of 6 characters but has gone back to edit the third character I need to know that it is the third character that is being edited and not the
second (or any other) character.


Maybe you are looking for the control's 'SelectionStart' property?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.