473,324 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

textbox and enter event

This seems like a simple one, ive searched the msdn and groups and cant
come up with the answer however.

I dont build gui apps very often (actually this is my first in oh 3
years)

I have a form and a textbox

When I put text in it and press enter I want it to DO SOMETHING, but I
cant find what event that is. When I press enter I just get the dink
sound. nothing happens, I tried the textchanged but that isnt it. This
is the only text box on the form

Ive been trying to figure this out for the last hour, and I cant imagine
what event this is.

The NEXT question I have is how would I fire an event that transforms
the input once a user has entered 10 digits ? But that second, if I cant
figure out the first it useless

Chris


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
5 6864
You can trap KeyDown and/or KeyPress events. KeyDown will occur first. You
can then use the properties of the xxxEventArgs, either e.KeyCode for
KeyDown (there's a bunch of others too) or e.KeyChar

HTH,

Bill
"Chris Wertman" <cw******@yahoo.com> wrote in message
news:um***************@TK2MSFTNGP11.phx.gbl...
This seems like a simple one, ive searched the msdn and groups and cant
come up with the answer however.

I dont build gui apps very often (actually this is my first in oh 3
years)

I have a form and a textbox

When I put text in it and press enter I want it to DO SOMETHING, but I
cant find what event that is. When I press enter I just get the dink
sound. nothing happens, I tried the textchanged but that isnt it. This
is the only text box on the form

Ive been trying to figure this out for the last hour, and I cant imagine
what event this is.

The NEXT question I have is how would I fire an event that transforms
the input once a user has entered 10 digits ? But that second, if I cant
figure out the first it useless

Chris


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
William Ryan eMVP wrote:
You can trap KeyDown and/or KeyPress events. KeyDown will occur
first. You can then use the properties of the xxxEventArgs, either
e.KeyCode for KeyDown (there's a bunch of others too) or e.KeyChar


If you want to get rid of the beep sound, you *must* trap the KeyPress event
and set e.Handled = True.

Doing this in the KeyDown event won't get rid of the sound.

--
Sven Groot
Nov 20 '05 #3
Hi Sven:

I agree with you. I thought he was asking how to do 'something' in a generic
sense when enter is pressed. From the post I gathered that he didn't want
to cancel the event, rather he was having trouble finding which event is
fired and "textchanged" wasn't doing it.

Either way, you raise a good point.
"Sven Groot" <sv*******@gmx.net> wrote in message
news:uU****************@TK2MSFTNGP10.phx.gbl...
William Ryan eMVP wrote:
You can trap KeyDown and/or KeyPress events. KeyDown will occur
first. You can then use the properties of the xxxEventArgs, either
e.KeyCode for KeyDown (there's a bunch of others too) or e.KeyChar
If you want to get rid of the beep sound, you *must* trap the KeyPress

event and set e.Handled = True.

Doing this in the KeyDown event won't get rid of the sound.

--
Sven Groot

Nov 20 '05 #4
Yeah that got it, looking on those keywords I found this

Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim keyCode As Int32 = Convert.ToInt32(e.KeyChar)
If keyCode = 13 Then

CheckedListBox1.Items.Add(TextBox2.Text)

End If

End Sub

Minus the french comments and supporting text, gotta love code, dosent
really matter what language you speak you can read it

Beyond KeyPress was what I was looking for as my barcode scanner I am
using about 50% of the time to enter in this field will send the ascii
13 at the end of the code.

once again duh......

Thanks all you guys are a lifesaver

Chris
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
Chris Wertman wrote:
Dim keyCode As Int32 = Convert.ToInt32(e.KeyChar)
I'd just like to add that the conversion to character code isn't necessary.
You can just compare e.KeyChar directly to ControlChars.Cr. It makes it more
clear which char you're checking for too.
Thanks all you guys are a lifesaver


You're welcome. ^_^

--
Sven Groot
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jose Egea | last post by:
Hello: I'm trying to execute a function when the user press Enter key in a TextBox. But something is happening in my form because after pressing a button, when I press the Enter key in the...
10
by: mg | last post by:
I want to enter characters in a TextBox in a WebForm, press a Button in the WebForm, and read the characters that were typed into the TextBox from within the Button_Click event handler. The main...
5
by: PD | last post by:
The TextChanged event is not being called when I hit the "Enter" key. Yet it does for the "Tab" key. I set a break point in the Page_Load event and the TextChanged event and none of these get...
7
by: djc | last post by:
I noticed that after entering text into a textbox on an asp.net webform and then hitting the enter key that a postback appears to be performed. 1) what event can I write to in order to perform an...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
10
by: Jane Sharpe | last post by:
Hi, I have a textbox with the words "Enter your name here" inserted as default text - At the moment, to remove this the user must highlight all the text and delete before they type in their name...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.