Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a custom Textbox control
Message
De
01/01/2016 19:32:32
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01629510
Message ID:
01629515
Vues:
31
>Can you check whether the event is actually fired? KeyPress and KeyDown handle keys differently and some keys don't trigger one or the other.
>
>Also you probably don't want to call the base method even with e.Handled set since you're essentially taking over that key event. The base call might affect your SendKeys logic.
>
>+++ Rick ---
>

Thank you, Rick

I'll take a look

>
>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform