|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
KeyDown eventI 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 "Helen Trim" <HelenT***@discussions.microsoft.com> schrieb The Enter key is caught by the KeyDown event by default.> 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? 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 Hello Armin
You're right about the Enter key. Thanks for your help, I think I understand now how to use inheritance and overrides. -- Show quoteHide quoteHelen "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 > >
Open a Text File in Notepad using VB.Net 2005
[Help] Reading data from a DLL structure in C Playing System Sounds/WAV files Where is ThisWorkbook.Sheets("xx") ?? Unable to resolve 'ThisWorkbook' :: Interop to Excel Datetime arithmetic in VB.Net? bindingsource running balance in datagrid what should i use? Structure Storage in Memory Different ways to go about storing data in an xml file.. |
|||||||||||||||||||||||