Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TextBox
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00763877
Message ID:
00763900
Views:
17
This message has been marked as the solution to the initial question of the thread.
Wilson,

You need to handle the KeyPress event. You check for whatever key you want to trap and then you can set the Handled property of the KeyEventArgs instance passed to your method to true and it will indicate that you have handled the event (and you do nothing, of course).

This example traps the Enter key:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
        e.Handled = True
    End If
End Sub
>How do i cancel a Key stroke in .NET. like in VB 6 by asigning 0 to the KeyAscii variable.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform