Format the input string in uppercase

Source: Internet
Author: User

Input characters are formatted in uppercase (only letters are allowed)
public class Letterbox:radtextbox
{
#region ToUpper

public enum Touppers
{
False,
True,
}

private touppers To_upper;
[DefaultValue (Touppers.false)]
Public touppers To_upper
{
Get
{
return to_upper;
}
Set
{
to_upper = value;
}
}

#endregion

protected override void OnKeyPress (System.Windows.Forms.KeyPressEventArgs e)
{
Base. OnKeyPress (e);

Setstandard (e);
}

private void Setstandard (System.Windows.Forms.KeyPressEventArgs e)
{
//Allow only letters to be entered
regex regex = new Regex ("^[a-za-z]");
MatchCollection mc = regex. Matches (E.keychar.tostring ());
foreach (Match MA in MC)
{
e.handled = false;
return;
}

E.handled = true;
}

protected override void OnTextChanged ( EventArgs e)
{
base. OnTextChanged (e);

if (ToUppers.True.ToString () = = To_upper.tostring ())
{
This. Text = this. Text.toupper ();
This. Select (text.length, 0);
}
}
}

Format the input string in uppercase

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.