Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a custom Textbox control
Message
De
01/01/2016 15:17:43
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Creating a custom Textbox control
Divers
Thread ID:
01629510
Message ID:
01629510
Vues:
53
I have often have a need for a textbox to tab to the next control when the user hits Enter, as it does with VFP.

I've been using this syntax and it works
  TextBoxHundreds.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SendTabonEnter);
    
 private void SendTabonEnter(object sender, KeyEventArgs e)
    {
      if (e.KeyCode == Keys.Return)
      {
        SendKeys.Send("{TAB}");
      }
    }
I've been trying to create a custom textbox control that has the behavior built in, with no success.
I found this syntax, but it doesn't work.
public class WSGTextbox : TextBox
    {

        protected override void  OnKeyDown(KeyEventArgs e)
        {
                if (e.KeyCode == Keys.Return)
                {
                    SendKeys.Send("{TAB}");
                }
                e.Handled = true;
            //  to Call the implementation in the base TextBox class,
            // which raises the KeyPress event.
            base.OnKeyDown(e);
        }



    }
Any ideas?
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform