473,788 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Click button when pressing enter key

erwinnnn
2 New Member
I'm a total noob on c#, i just started 2 weeks ago
I'm making a calculator

Its very simple..
When i press the enter key, button1 must be clicked
It works with all the other keys, but with the enter key it DOESN'T WORK :(
I've searched on google for hours and i tried almost everything, but nothing works..

So please, help me
Thx
Mar 20 '08 #1
4 1500
int08h
28 New Member
if you are developing a WinForm, the "AcceptButt on" property of the form makes sense.
Mar 21 '08 #2
shweta123
692 Recognized Expert Contributor
Hi,

You can refer This Article for handling keypress event for Win Form.
Mar 21 '08 #3
balabaster
797 Recognized Expert Contributor
Take the code out of your button click event and create a sub called Totalize or something descriptive. Put the code from the button click event in this sub
Expand|Select|Wrap|Line Numbers
  1. Public Sub Form1_KeyPress(....) Handles Form1.Keypress
  2.   If (e.KeyCode = Keys.Enter) Or (e.KeyCode = Keys.Return) Then
  3.     Totalize()
  4.   End If
  5. End Sub
  6.  
  7. Public Sub Button1_Click(....) Handles Button1.Click
  8.   Totalize()
  9. End Sub
That should do what you're looking for.
Mar 21 '08 #4
erwinnnn
2 New Member
Ok, thank you for your help
Mar 24 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9591
by: ivanhoe | last post by:
All articles and tutorials I've seen on subject of forms say that if there's name and value for submit button(input tag with type="submit"), they'll get submitted along with the rest of the form... but I've just noticed (after debugging my perl script for quite a while :/ ) that it is true only when user clicks on submit, and if form is submitted via hitting enter you don't get name=value for submit buttton...
2
1959
by: adolf garlic | last post by:
I'm having a problem with a button click event being fired erroneously. My login.aspx page has the usual username/password boxes. There is also a link to click when you have filled these, plus a 'remember me' checkbox. Further down the page we have a 'email me my password' button. In addition there is also a small piece of client side script to handle the user pressing the 'enter' key (this has the same effect as clicking the
1
1539
by: George Homorozeanu | last post by:
Hi, I have an ASP.Net Page with some control on it (buttons, textboxes, calender, etc). When I'm changing the text in the textbox I want to run some code and change the date of the calendar. The problem is that when I press enter, the code for the button event is called. It looks like the button is the default action for pressing enter somewhere on the page. How can I change that? The button is an asp button. Thanks,
1
2025
by: dhnriverside | last post by:
Hi I've got a form with a TextBox and an invisible button, and I've got it set so that pressing enter causes the button to click. WOrks fine, the forms submits on enter and my datalist refreshes (tis a search textbox/list). I'm trying to implement AJAX style behaviour (its an intranet) - so as you type in the box, it refreshes the results list. So far I've tried OnKeyPress="TextChange" - where TextChange is a public C#
12
7387
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items into a datagrid. When a user presses the enter key on this button I want the mouse click event to be activated but instead the tab page's validating event is called. I understand that this behaviour is by partly by design (Accept button etc) but I...
1
4659
by: Joey | last post by:
I have an asp.net 1.1/C# web form with a text box server control and one button server control. Users can type in text to search and then click the button to start the search. I want them to be able to type in text and then just hit the Enter key instead of having to click the button. Currently, an Enter keypress causes a post back, but it does not fire the event handler for the button click. How can I get this to work?
3
6086
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I have two sets of search criteria on my page. They are placed inside two DIV tags made visible/hidden by a client script. In each DIV tag I have a LinkButton that performs the search from each set. By using AJAX I get the resulting list expand and collapse without page reload. All work smoothly. But one user today complained that the submit behaviour doesn't work like before.
1
8824
by: RyanT | last post by:
Access 2000 Windows XP I have a small form with two text boxes: - User ID - Password The form also has two command buttons: - Login - Cancel
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.