public override bool Validate() { OnValidating();//Call anyone who is listening Validated event if (!Enabled) { return(UpdateResult(true)); } try { string value = ControlToValidate.GetType().GetProperty(PropertyToValidate).GetValue(ControlToValidate, null).ToString().Trim(); string compareValue = ControlToCompare.GetType().GetProperty(PropertyToValidate).GetValue(ControlToCompare, null).ToString().Trim(); if (value == compareValue) { return(UpdateResult(true)); } return(UpdateResult(false)); } catch (Exception ex) { if (ShowExceptions) { MessageBox.Show(ex.Message.ToString(), "Exception occured!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return(UpdateResult(false)); } }
public override bool Validate() { OnValidating();//Call anyone who is listening Validated event if (!Enabled) { return(UpdateResult(true)); } try { String value = ControlToValidate.GetType().GetProperty(PropertyToValidate).GetValue(ControlToValidate, null).ToString().Trim(); System.Text.RegularExpressions.Regex evaluator = new System.Text.RegularExpressions.Regex(ExpressionPattern); if (evaluator.IsMatch(value)) { return(UpdateResult(true)); } return(UpdateResult(false)); } catch (Exception ex) { if (ShowExceptions) { MessageBox.Show(ex.Message.ToString(), "Exception occured!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return(UpdateResult(false)); } }