VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Pressing enter in Textbox Posted by saphiroth on 28 Dec 2004 at 7:02 AM
How can I make the program do something when a person presses enter after pressing the Enter key on the keyboard? What does the textbox need to handle a Enter key press event?

Thanx
Report
Re: Pressing enter in Textbox Posted by HyBRiD_HeLL on 30 Dec 2004 at 6:01 AM
: How can I make the program do something when a person presses enter after pressing the Enter key on the keyboard? What does the textbox need to handle a Enter key press event?
:
: Thanx
:


If Keys.Enter Then :)
-Simple isn't it:))
Report
Re: Pressing enter in Textbox Posted by Baldusarius on 30 Dec 2004 at 9:17 AM
KeyPressEventArgs does not have a property that returns a value from the Keys enumeration.

I'm assuming you are directing him to use the KeyDown event, which has a parameter of type KeyEventArgs. Although it would be more convenient to use that event because no conversion is required to use the Keys enumeration, you get an annoying system beep if you try to handle the enter key there. Most people would not be happy with that, so the more correct answer is to handle KeyPress.

: : How can I make the program do something when a person presses enter after pressing the Enter key on the keyboard? What does the textbox need to handle a Enter key press event?
: :
: : Thanx
: :
:
:
: If Keys.Enter Then :)
: -Simple isn't it:))
:

Report
Re: Pressing enter in Textbox Posted by Baldusarius on 30 Dec 2004 at 9:11 AM
Handle the KeyPress event of the TextBox. If you try to handle it in the KeyDown event, you'll get an annoying system beep.

Private Sub TextBox1_KeyPress(ByVal sender As Object, _
   ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
   TextBox1.KeyPress
   
   If e.KeyChar = Convert.ToChar(Keys.Enter) Then
      
      DoSomething();

      'This tells the system not to process
      'the key, as you've already taken care 
      'of it 
      e.Handled = True 
   End If

End Sub



: How can I make the program do something when a person presses enter after pressing the Enter key on the keyboard? What does the textbox need to handle a Enter key press event?
:
: Thanx
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.