Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inputmask for Textbox
Message
De
16/11/2012 06:20:47
 
 
À
15/11/2012 11:29:56
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01557193
Message ID:
01557421
Vues:
42
>>>Set Textbox.Max.Length =2, TextBox.CharacterCasing = CharacterCasing.Upper
>>
>>Is there anything similar to force the first character entered in a text box to upper case and the rest can be mixed case?
>>
>>similar to VFP's InputMask = "!XXXX"
>
>Not tested:
protected override void OnKeyUp(System.Windows.Input.KeyEventArgs e)
>       {
>         base.OnKeyUp(e);
>         if (this.Text.Length == 1)
>         {
>           this.Text = this.Text.ToUpper();
>           this.CaretIndex = 1;
>         }
>       }
>
>Update: Thinking about it - that won't work if the user backs up (for example by using left arrow). Maybe somewhere else (eg. LostFocus:
protected override void OnLostFocus(RoutedEventArgs e)
>       {
>         Text = Text.Substring(0, 1).ToUpper() + Text.Substring(1);
>         base.OnLostFocus(e);
>       }
Thanks, I'll try stuff like this out. I wonder how come simple things like this weren't included as standard.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform