Click here to Skip to main content
16,018,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
just to disable Tab key in all over my windows form application, because when the user hit Tab key validation routine in textbox skipped

What I have tried:

C#
{
            if (e.KeyCode == Keys.Enter)
 
            {
   
            }

           e.Handled = ProcessKeyDown(e.KeyCode);
           SendKeys.Send("{TAB}");
           if (e.KeyCode == Keys.Tab && string.IsNullOrEmpty(textBox1.Text))
          {
              textBox1.Focus();
               return;
Posted
Updated 25-Aug-20 6:48am
v2

1 solution

Don't even try to disable TAB - you will annoy more users that you can believe ...

Instead, do the validation when you leave the TextBox - there is an event for just that (or in fact several):
Control.Leave Event (System.Windows.Forms) | Microsoft Docs[^]
Control.LostFocus Event (System.Windows.Forms) | Microsoft Docs[^]
Control.Validating Event (System.Windows.Forms) | Microsoft Docs[^]
have a look and decide which is best - but disabling "standard navigation" controls is never a good idea - users will hate it, and by extension your app and you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900