>>Hi,
>>
>>I have a textbox that I want to limit a user to only entering two characters (could be any characters, numbers or anything on the keyboard). I would love to force them to upper case if they are letters and only allow two characters.
>>
>>The VFP equivalent of inputmask = "!!"
>>
>>Any ideas?
>
>Set Textbox.Max.Length =2, TextBox.CharacterCasing = CharacterCasing.Upper
>then:
protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)
> {
> char c = e.Text.ToCharArray()[0];
> if (Char.IsControl(c) || Char.IsLetterOrDigit(c))
> base.OnPreviewTextInput(e);
> else
> {
> e.Handled = true;
> }
> }
>
>Update: Just noticed you don't actually care what the characters are so the override isn't neccessary. Still it may give you an idea of how this approach could be expanded in future :-}
Thanks Viv, I was going to ask why the code was necessary, but at least it is a good example of what I can do in the future.