class NumericTextBox : TextBox { private string _InputMask = "###,###,##0.00"; /// <summary> /// Máscara que usará el valor digitado /// </summary> public string InputMask { get { return _InputMask; } set { _InputMask = value; } } // Declaración de método delegado public delegate void EventHandler(object sender,EventArgs e); #region constructor public NumericTextBox() { this.Height = 20; this.Width = 100; this.KeyPress += this.NumericTextBox_KeyPress; // declara el metodo que funcionará como eventhandler this.TextAlign=HorizontalAlignment.Right; } #endregion constructor #region Keypress // Método que maneja el evento Keypress public void NumericTextBox_KeyPress(object sender, KeyPressEventArgs e) { char _caracter; if (Char.IsDigit(e.KeyChar) | e.KeyChar == '.' ) { _caracter=e.KeyChar; // Si el punto ya existe en el texto if (_caracter == '.' & this.Text.Contains(_caracter.ToString())) { e.Handled = true; } } else { e.Handled = true; } } #endregion Keypress # region Validated protected override void OnValidated(EventArgs e) { string Valor=this.Text; double dValor=Double.Parse(Valor); Valor=dValor.ToString(_InputMask); this.Text = Valor; base.OnValidated(e); } #endregion Validated }>Hi,