ALX
Well-known member
I have a small message form set up with 5 or so labels and a cancel button. I want the labels to change background color as the user presses the up or down keys. It seems that I can trap all key events except the up and down keys. I've tried many combinations of:
-----------------------------------
-----------------------------------
-----------------------------------
The KeyPreview for the form is set to TRUE. I've tried versions using the
method. Nothing seems to be able to trap the arrow keys. I prefer using labels rather than buttons on this form because it is used mostly as messaging window and only needs to be able to highlight selected labels for one or two short applications.
I'm using Visual Studio.NET 2003...... 'Any ideas what I'm doing wrong ?
-----------------------------------
VB.NET:
Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
If e.KeyChar = ChrW(38) Then
e.Handled = True
'<...process color here ...>
Else
MyBase.OnKeyPress(e)
End I
VB.NET:
Private Sub Form1_KeyPress (ByVal sender As Object, ByVal e As _
system.Windows.Forms.KeyPressEventArgs) _ Handles MyBase.KeyPress
If e.KeyChar = ..... an so on ...
The KeyPreview for the form is set to TRUE. I've tried versions using the
VB.NET:
"AddHandler KeyDown, AddressOf ..."
I'm using Visual Studio.NET 2003...... 'Any ideas what I'm doing wrong ?