"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