Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i made (0~9)buttons as i want to click the button (instead of pressing it on keyboard )
ex: i click on btn5 then textbox1.text &="5"
. but when i click on any button then press on enter key (the button will be pressed automatically and that what i do not want )

What I have tried:

i have tried to write on textbox just by click on buttons without using any keys (on keyboard)
Posted
Updated 4-Jul-18 8:11am
Comments
Patrice T 4-Jul-18 14:54pm    
Because your secret code is wrong and your need to apply a secret correction.

1 solution

You really shouldn't do that - it is the default and expected behaviour for windows, and you mess with that at your peril. Users do know that ENTER activates a button, and if you don't specify a button to "accept" the ENTER, the currently focused control gets it.

The best solution would be to make ENTER press the "Equals" button - which is simple to do.
In your form, override ProcessCmdKey:
VB
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
    If keyData = Keys.Enter Then
        buttonEquals.PerformClick()
        Return True
    End If

    Return MyBase.ProcessCmdKey(msg, keyData)
End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900