Getting text box value on key press?

B

Brett Romero

I have three text boxes on a form with one button. The button is the
form's AcceptButton. After some one puts a value into any text box, I
assign the value to an object via textbox.Leave() event. This doesn't
work if some one types or pastes in a value then hits <enter>. None of
the key events are captured. The button click event is fired.

I could just capture textbox values in the search button click event.
However, I'd like to get them in real-time. Another option is to
capture on keyup() so that I get values as the user types them. That's
to much overhead and inefficient should I want to make use of those key
events for something. I also need to capture a pasting values into the
textbox.

Any suggestions?

Thanks,
Brett
 
B

Brett Romero

Text boxes don't have a change event, at least in 2.0. Besides, you
would still execute that code upon each letter the user is typing in,
which I don't want. Probably works well only for pasting into the box.

Thanks,
Brett
 
J

JustinC

Brett,

There is a TextChanged event in textboxes, and pasting text into the
textbox will fire this event.

I hope this helps ~ Justin
 
B

Brett Romero

Justin,

That probably works fine when they paste into the box. But it will
still fire after every key press.

Brett
 

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

Top