-
VB.Net 2003 FORM KEYDOWN problem
Hi There,
I am developing VB.NET 2003 window application having problem with the FORM KEYDOWN event.
Problem with cancelling the keydown event when the data check function return FALSE due to duplicate Debtor ID.
How to cancel the KeyDown ?
Code:
Private Sub FrmDebtor_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Tab Or e.KeyCode = keys.Enter Then
If Me.TabIndex = 1 Then
If FCheckDuplicate = True Then
e.KeyCode = Keys.Cancel
End If
End If
End If
End sub
Last edited by Hack; 12-22-2009 at 07:22 AM.
Reason: Added Code Tags
Cheers,
Lennie
-
Try
Code:
e.Handled - True
'or
e.SuppressKeyPress = True
-
Thanks Hack,
Will try it out and if it works will post the script here to share with others.
Cheers,
Lennie
-
Hi Hack
To try out your suggestion, I have modified the script that I initially posted here as per samplel listed below. Surprising, the TAB key action is not working while ENTER is.
Private Sub FrmDebtor_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Tab and ( Me.TabIndex = 1 ) Then
If FCheckDuplicate = True Then
e.handled = false
End If
End If
End sub
Last edited by Lennie; 12-22-2009 at 05:46 PM.
Cheers,
Lennie
-
Are you sure that when you hit TAB that Me.TabIndex = 1 is true?
-
Hi Hack,
Are you sure that when you hit TAB that Me.TabIndex = 1 is true?
Yes, it's true. Have you tried it ?
Cheers,
Lennie
-
You cannot capture the Tab key in the KeyDown (or any other) event; the control processes the Tab key before it fires the event. See if this helps: http://support.microsoft.com/kb/327821
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Hi Phil,
Thank you very much for your information and the URL Link. That are indeed good Christmas present.
Cheers,
Lennie
Similar Threads
-
By pfaisalbe in forum .NET
Replies: 4
Last Post: 05-21-2009, 09:36 PM
-
By kgarthai in forum AJAX
Replies: 0
Last Post: 02-19-2007, 08:31 PM
-
Replies: 0
Last Post: 12-11-2002, 05:05 AM
-
Replies: 1
Last Post: 01-04-2002, 03:32 AM
-
Replies: 3
Last Post: 11-23-2001, 04:11 PM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|