Do not spray, thank you!!!
Allow input of shaping numbers and BACKSPACE keys
Using System.Windows.Forms;
Namespace BaseDataMaintain.Views.Controls
{
<summary>
int input textbox
</summary>
public class TextIntNumBox:Telerik.WinControls.UI.RadTextBox
{
protected override void OnKeyPress (System.Windows.Forms.KeyPressEventArgs e)
{
Base. OnKeyPress (e);
Not allowed at the beginning.
if (SelectionStart = = 0)
{
if (E.keychar = = ' 0 ')
//{
E.handled = true;
Return
//}
if (E.keychar = = '-')
{
e.handled = false;
Return
}
if (E.keychar = = ' 1 '
|| E.keychar = = ' 2 '
|| E.keychar = = ' 3 '
|| E.keychar = = ' 4 '
|| E.keychar = = ' 5 '
|| E.keychar = = ' 6 '
|| E.keychar = = ' 7 '
|| E.keychar = = ' 8 '
|| E.keychar = = ' 9 '
|| E.keychar = = ' \b ')
{
e.handled = false;
Return
}
}
You can only follow after 0. Add 2014.11.27
if (this. Text.trim (). StartsWith ("0") && e.keychar! = ' \b ')
{
E.handled = true;
Return
}
Only numbers + Backspace
if (E.keychar = = ' 0 '
|| E.keychar = = ' 1 '
|| E.keychar = = ' 2 '
|| E.keychar = = ' 3 '
|| E.keychar = = ' 4 '
|| E.keychar = = ' 5 '
|| E.keychar = = ' 6 '
|| E.keychar = = ' 7 '
|| E.keychar = = ' 8 '
|| E.keychar = = ' 9 '
//|| E.keychar = = '. '
|| E.keychar = = ' \b ')
{
e.handled = false;
}
Else
{
E.handled = true;
}
}
Supports copy, clip, paste, Ctrl + A
protected override bool processCmdKey (ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (KeyData = = (Keys.control | KEYS.A))
{
This. SelectAll ();
}
if (KeyData = = (Keys.control | KEYS.C))
{
This. Copy ();
}
if (KeyData = = (Keys.control | keys.x))
{
This. Cut ();
}
if (KeyData = = (Keys.control | KEYS.V))
{
This. Paste ();
}
Return base. processCmdKey (ref msg, keyData);
}
}
}
Radtextbox allows you to enter shaping numbers and BACKSPACE keys