public static void addEventTag(Control controls, TIPOS tipo, string tag) { foreach (Control cCur in controls.Controls) { if (cCur.Tag != null) { if (cCur.Tag.ToString().Trim().ToLower() == tag.Trim().ToLower()) { switch (tipo) { case TIPOS.TEXTO: cCur.TextChanged += new EventHandler(cCur_CheckText); break; case TIPOS.DECIMAL: cCur.TextChanged += new EventHandler(cCur_CheckNumber); break; case TIPOS.MOEDA: TextBox tbox = cCur as TextBox; tbox.Validator = new TextBoxValidation("", "", "0-9\\."); cCur.TextChanged += new EventHandler(cCur_CheckCurrency); //cCur.KeyPress += new KeyPressEventHandler(cCur_KeyPressCurrency); // cCur.KeyUp += new KeyEventHandler(cCur_KeyUp); break; default: cCur.TextChanged += new EventHandler(cCur_CheckText); break; } } } } }
public static void addEventType(Control controls, TIPOS tipo, params Type[] setTypes) { foreach (Control cCur in controls.Controls) { bool bSet = false; foreach (Type t in setTypes) { if (cCur.GetType() == t) { bSet = true; break; } } if (bSet) { switch (tipo) { case TIPOS.TEXTO: cCur.TextChanged += new EventHandler(cCur_CheckText); break; case TIPOS.DECIMAL: cCur.TextChanged += new EventHandler(cCur_CheckNumber); break; default: cCur.TextChanged += new EventHandler(cCur_CheckText); break; } } } }