0

I am now trying to change the status of check boxes (checked or unchecked) by pressing the enter key from the keyboard. I searched through on the web, and I am not lucky enough to get what I want. Because I set up to go through all the fields by pressing the tab button on the keyboard, having to go for the mouse and move it and click on the check box seems a little irritating. So, there must be a way to change the status of the check box(es) just by pressing the enter key from the keyboard. Can anyone help me with this, please? Thanks in advance.

Honey Aung
  • 13
  • 3
  • 2
    Sure, this can be done. But why don't you just use the Space key instead of the Enter key? This is the standard way to change the state of a CheckBox using the keyboard and you don't have to write any code for it. You're trying to change the state while the CheckBox is selected, right? Also, are you using VB.NET or VB6? Those are two different languages. – 41686d6564 stands w. Palestine Sep 29 '22 at 05:11
  • Hi, thank you very much for the fast reply. I am using vb.net and why I want to use Enter key is most of the data I need to type are numbers. So, to press the enter key at the lower right corner of the numpad is a lot easier for me to press. – Honey Aung Sep 29 '22 at 05:30
  • 1
    Does this answer your question? [Detecting Enter keypress on VB.NET](https://stackoverflow.com/questions/2752424/detecting-enter-keypress-on-vb-net) – 41686d6564 stands w. Palestine Sep 29 '22 at 05:32
  • Assuming the name of your CheckBox is `CheckBox1`, type the following in the `KeyDown` event handler of that CheckBox: `If e.KeyData = Keys.Enter Then CheckBox1.Checked = Not CheckBox1.Checked`. – 41686d6564 stands w. Palestine Sep 29 '22 at 05:34
  • Horray! It works! Thank you very much sir! I do appreciate your help. if e.keydata = keys.enter did the magic. Thanks – Honey Aung Sep 29 '22 at 09:37

0 Answers0