473,396 Members | 1,965 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,396 software developers and data experts.

KeyDown event

I am struggling to get the keydown event for checkboxes to work when pressing
down arrow and enter. The so-called help talks about overriding the
IsInputKey method for the controls, but doesn't give an example. How do I
override a control's method?
TIA
--
Helen
Mar 15 '06 #1
2 1899
"Helen Trim" <He*******@discussions.microsoft.com> schrieb
I am struggling to get the keydown event for checkboxes to work when
pressing down arrow and enter. The so-called help talks about
overriding the IsInputKey method for the controls, but doesn't give
an example. How do I override a control's method?

The Enter key is caught by the KeyDown event by default.

If you want to override a method, derive a class from the Checkbox class and
override the method by choosing "overrides" and "IsInputKey" from the
comboboxes at the top of the code editor. Results in

Protected Overrides Function IsInputKey( _
ByVal keyData As System.Windows.Forms.Keys) _
As Boolean

If keyData = Keys.Down Then
Return True
Else
Return MyBase.IsInputKey(keyData)
End If

End Function
If you want to use the designer to replace the standard Checkbox by your own
derived Checkbox, you have to compile, add it to the toolbox and put it on
the Form. Unfortunatelly, only own controls derived from UserControl are put
automatically in the toolbox.
Armin

Mar 15 '06 #2
Hello Armin

You're right about the Enter key. Thanks for your help, I think I
understand now how to use inheritance and overrides.

--
Helen
"Armin Zingler" wrote:
"Helen Trim" <He*******@discussions.microsoft.com> schrieb
I am struggling to get the keydown event for checkboxes to work when
pressing down arrow and enter. The so-called help talks about
overriding the IsInputKey method for the controls, but doesn't give
an example. How do I override a control's method?

The Enter key is caught by the KeyDown event by default.

If you want to override a method, derive a class from the Checkbox class and
override the method by choosing "overrides" and "IsInputKey" from the
comboboxes at the top of the code editor. Results in

Protected Overrides Function IsInputKey( _
ByVal keyData As System.Windows.Forms.Keys) _
As Boolean

If keyData = Keys.Down Then
Return True
Else
Return MyBase.IsInputKey(keyData)
End If

End Function
If you want to use the designer to replace the standard Checkbox by your own
derived Checkbox, you have to compile, add it to the toolbox and put it on
the Form. Unfortunatelly, only own controls derived from UserControl are put
automatically in the toolbox.
Armin

Mar 15 '06 #3

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

Similar topics

3
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
4
by: Tony | last post by:
I'm building a simple "breakout" style video-game, and I want keyboard control of the paddle. What I need is for an event handler to respond whenever a key is pressed, regardless of what the...
4
by: Anne | last post by:
hie again, i have 3 textbox and i would like the user to go to the next textbox by pressing the 'ENTER' key. i have tried using this: Private Sub txtRequestor_KeyDown(ByVal sender As...
4
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As...
1
by: fripper | last post by:
I have a VB 2005 windows app and I want to recognize keydown events. I have a form key down event handler but it does not get control when a key is depressed. In playing around I found that if I...
0
by: tony | last post by:
Hello!! I have a derived class called StringClassEditor which inherit from UITypeEditor listed below. Now to my question in method EditValue in this class I have this statement lb.KeyDown ...
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
3
by: win | last post by:
when the cursor is in a textbox, only coding in the keydown event of the textbox triggered, the coding in the keydown event of the form does not triggered! Problem: I need to change a VB6 program...
2
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.