I have a problem with a custom TextBox control that I created and to which I added several events, among which is the KeyPress in which I used currency format, until then everything works fine.
My problem is that when I want to add specific validations to the control in the projects that inherit from it, it is as if I do not recognize the events created in the control.
Eg: the control validates that the entered string is numeric: Ok
A part if I want to validate that it does not contain the number 5 in the project where it inherits it, it does not recognize it.
public class CajaDeTexto : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
try
{
if (IsEnter(e))
{
this.SelectionStart = this.Text.Length;
Tab();
}
if (EJ_Mayúsculas) { KeyPressMayusculas(e); }
if (EJ_SoloNumero) { KeyPressNumeros(ref e); }
if ((EJ_Dinero) | (EJ_ValorMinimo != 0 | EJ_ValorMaximo != 0) | (EJ_Decimales)) { KeyPressDinero(ref e); }
if (EJ_Cedula) { KeyPressIdentificacion(ref e); }
}
catch (Exception ex)
{ throw ex; }
}
}
En el proyecto donde uso el control, no reconoce algo como esto:
private void cajaDeTexto1_KeyPress(object sender, KeyPressEventArgs e)
{
//Ejemplo
if(e.KeyChar ==(char)Keys.Enter)
{
Guardar();
}
}