Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inputmask for Textbox
Message
From
16/11/2012 06:20:47
 
 
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01557193
Message ID:
01557421
Views:
41
>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform