Home All Groups Group Topic Archive Search About
Author
15 Mar 2006 1:37 PM
Helen Trim
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

Author
15 Mar 2006 2:03 PM
Armin Zingler
"Helen Trim" <HelenT***@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
Author
15 Mar 2006 2:55 PM
Helen Trim
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


Show quoteHide quote
"Armin Zingler" wrote:

> "Helen Trim" <HelenT***@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
>
>