The only one methods in the OnKeyPress (overrided) and accept only digit or the backspace
using System;To use it you just drag & drop the control from the toolbox to your form.
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DrLuiji.Controls
{
public class NumericTextBox : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (!((Char.IsDigit(e.KeyChar))||(e.KeyChar.Equals('\b'))))
{
e.Handled = true;
ErrorBeep();
}
}
public void ErrorBeep()
{
//Console.Beep();
}
}
}
Have fun.