|
-
Jul 13th, 2004, 01:32 PM
#1
Thread Starter
Lively Member
Escape Key Press Problem !
Private Sub Form_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
If KeyCode = 27 Then
MessageBox.Show("You Click The Escape Key")
Me.currentage_TextBox.Undo()
End If
End Sub
why i click the escape key and it wont work ????
some one please help me thanx
-
Jul 13th, 2004, 01:33 PM
#2
Hyperactive Member
Do you have KeyPreview turned on for the form?
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 01:49 PM
#3
Thread Starter
Lively Member
yes i turn it on already
when i press the escape key it didnt show any action
at the keyPreview there i set to true already
Last edited by ninjaX; Jul 13th, 2004 at 01:53 PM.
-
Jul 13th, 2004, 02:00 PM
#4
Hyperactive Member
you aren't referencing the appropriate objects.
Try replacing your code with this
VB Code:
Private Sub frmAbout_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.Escape Then
Me.TextBox1.Undo()
End If
End Sub
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 02:09 PM
#5
Thread Starter
Lively Member
thanx ~
it works
i got another problem can you help me to solve ???
how can i detect which textbox i am using ???
example i have change the textbox value and i need to undo it how can i know which textbox is change ???
-
Jul 13th, 2004, 02:15 PM
#6
Hyperactive Member
this will do the trick 
VB Code:
Private Sub frmAbout_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.Escape Then
Dim txtWork As New TextBox
If Me.ActiveControl.GetType.Equals(txtWork.GetType) Then
txtWork = DirectCast(Me.ActiveControl, TextBox)
txtWork.Undo()
End If
End If
End Sub
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 02:17 PM
#7
Frenzied Member
Keep a form level reference object that you set to the sender value of the onChange event for the text box.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jul 13th, 2004, 08:54 PM
#8
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|