Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a custom Textbox control
Message
From
01/01/2016 15:17:43
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Creating a custom Textbox control
Miscellaneous
Thread ID:
01629510
Message ID:
01629510
Views:
51
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.
Next
Reply
Map
View

Click here to load this message in the networking platform