private void bd_ParseInt(object sender, ConvertEventArgs e) { int num; Predicate <InputRangeDec> match = null; Binding bd = sender as Binding; if (int.TryParse(e.Value.ToString(), out num)) { if (match == null) { match = c => c.Name == bd.BindingMemberInfo.BindingField; } InputRangeDec dec = this.inputRanges.Find(match); if (dec != null) { if (dec.CheckIt(ref num)) { bd.Control.BackColor = Color.WhiteSmoke; e.Value = num; } else { bd.Control.BackColor = Color.Salmon; } } } else { e.Value = null; } }
private void bd_Parse(object sender, ConvertEventArgs e) { decimal num; Binding bd = sender as Binding; InputRangeDec dec = this.inputRanges.Find(c => c.Name == bd.BindingMemberInfo.BindingField); if (string.IsNullOrEmpty(e.Value.ToString())) { e.Value = null; return; } if (decimal.TryParse(e.Value.ToString(), out num)) { if (dec != null) { if (dec.CheckIt(ref num)) { bd.Control.BackColor = Color.WhiteSmoke; dec.ErrorInput = false; //e.Value = num; } else { bd.Control.BackColor = Color.Salmon; dec.ErrorInput = true; } } } else { e.Value = null; bd.Control.BackColor = Color.WhiteSmoke; dec.ErrorInput = false; } }