|
-
Dec 31st, 2007, 02:35 PM
#1
Thread Starter
Addicted Member
[2008] Detect tab?
Hi all,
I want to detect when the user press tab in a textbox, instead of moving to the next control
I also want to be able to know when the user press tab and when the computer sendkeys tab
-
Dec 31st, 2007, 02:53 PM
#2
Re: [2008] Detect tab?
AFAIK, there is no real way to tell if the textbox is receiving a physical tab keypress or is receiving a sendkeys tab keypress.
Why do you need to know the difference?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 1st, 2008, 05:11 AM
#3
Re: [2008] Detect tab?
You would need to inherit the TextBox class and override the ProcessCmdKey method to filter out the Tab key:
vb.net Code:
Public Class TextBoxEx Inherits TextBox Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _ ByVal keyData As System.Windows.Forms.Keys) As Boolean Return (keyData And Keys.Tab) = Keys.Tab OrElse _ MyBase.ProcessCmdKey(msg, keyData) End Function End Class
As far as the control is concerned there is no difference. It gets the same message from Windows either way.
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
|