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

KeyPress Event

P: n/a
I want to read the text property of a textbox from within the KeyPress event.
The text property does not show the last character entered. That character
can be found using e.KeyChar parameter value, but if the user moves the caret
to another position other that the end of the text, that character would not
be in the last position of the text.

Is there a way to know which position of text contains the character
entered?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* "=?Utf-8?B?Q2hhcmxpZQ==?=" <Ch*****@discussions.microsoft.com> scripsit:
I want to read the text property of a textbox from within the KeyPress event.
The text property does not show the last character entered. That character
can be found using e.KeyChar parameter value, but if the user moves the caret
to another position other that the end of the text, that character would not
be in the last position of the text.

Is there a way to know which position of text contains the character
entered?


Take a look at the textbox's 'SelectionStart' and 'SelectionLength'
properties.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
Thank you!!!

"Herfried K. Wagner [MVP]" wrote:
* "=?Utf-8?B?Q2hhcmxpZQ==?=" <Ch*****@discussions.microsoft.com> scripsit:
I want to read the text property of a textbox from within the KeyPress event.
The text property does not show the last character entered. That character
can be found using e.KeyChar parameter value, but if the user moves the caret
to another position other that the end of the text, that character would not
be in the last position of the text.

Is there a way to know which position of text contains the character
entered?


Take a look at the textbox's 'SelectionStart' and 'SelectionLength'
properties.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.