TextBox KeyDown event

C

Colin McGuire

Hi, can I ask what I should be doing below. For some reason the method
KeyDown doesn't exist in MyBase.
Thank you
Colin


Private Sub TextBox1_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles TextBox1.KeyDown
'
'if something then
' possibly do some things
'end if
'
MyBase.KeyDown(sender, e) 'ERROR HERE, KEYDOWN DOESN'T EXIST
End Sub

BTW, and not that relevant, the 'things' I am wanting to do in the
if/endif structure is detect if a pound, euro, or dollar character is
present, then change the currency in a combobox elsewhere on the form
to show the correct currency. But I still want my keys to be processed
normally so I want to call MyBase.KeyDown and this is why I am trying
to.
 
C

Cor

Hi Colin,

Easier is to use the keyUp event.
and then something as
e.keyData =
gives you direct all keys
e.keyvalue =
But you see them when you are busy,
start with key.data just to try.

I hope this helps?


Cor
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Colin McGuire) scripsit:
Hi, can I ask what I should be doing below. For some reason the method
KeyDown doesn't exist in MyBase.

'KeyDown' is an event handler.
Private Sub TextBox1_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles TextBox1.KeyDown
'
'if something then
' possibly do some things
'end if
'
MyBase.KeyDown(sender, e) 'ERROR HERE, KEYDOWN DOESN'T EXIST

You don't need that.
End Sub

BTW, and not that relevant, the 'things' I am wanting to do in the
if/endif structure is detect if a pound, euro, or dollar character is
present, then change the currency in a combobox elsewhere on the form
to show the correct currency. But I still want my keys to be processed

Have a look at the properties of 'e' passed to the procedure.
 
B

Brian

You call Mybase only when you override an event. Which you didn't do in this
case.

Example:
Protected Overrides Sub OnKeyDown(ByVal e As
System.Windows.Forms.KeyEventArgs)
'--Do whatever


MyBase.OnKeydown(e)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top