private void bd_ParseStr(object sender, ConvertEventArgs e) { string str = e.Value as string; Binding bd = sender as Binding; InputRangeStr str2 = this.inputrange_str.Find(c => c.Name == bd.BindingMemberInfo.BindingField); if (str2 != null) { if (!string.IsNullOrEmpty(str2.StrRegex) && (string.IsNullOrEmpty(str) || !Regex.IsMatch(str, str2.StrRegex))) { str2.ErrorInput = true; bd.Control.BackColor = Color.Salmon; } else if (Encoding.GetEncoding("GB2312").GetByteCount(str) > str2.BytesCount) { str2.ErrorInput = true; bd.Control.BackColor = Color.Salmon; } else { str2.ErrorInput = false; bd.Control.BackColor = Color.WhiteSmoke; } } }
private void tbReason_TextChanged(object sender, EventArgs e) { TextBox tb = sender as TextBox; InputRangeStr str = this.inputrange_str.Find(c => c.Name == tb.Name); if (Encoding.GetEncoding("GB2312").GetByteCount(tb.Text) > str.BytesCount) { str.ErrorInput = true; tb.BackColor = Color.Salmon; } else { str.ErrorInput = false; tb.BackColor = Color.WhiteSmoke; } }
private void bd_ParseIdentifyCard(object sender, ConvertEventArgs e) { string card = e.Value as string; Binding bd = sender as Binding; InputRangeStr str2 = this.inputrange_str.Find(c => c.Name == bd.BindingMemberInfo.BindingField); if (str2 != null) { if (!this.IsIdentifyCard(card)) { str2.ErrorInput = true; bd.Control.BackColor = Color.Salmon; } else { str2.ErrorInput = false; bd.Control.BackColor = Color.WhiteSmoke; } } }
void bd_ParseStr(object sender, ConvertEventArgs e) { string str = e.Value as string; Binding bd = sender as Binding; InputRangeStr input = inputrange_str.Find(c => { return(c.Name == bd.BindingMemberInfo.BindingField); }); if (input != null) { int length = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(str); if (length > input.BytesCount) { input.ErrorInput = true; bd.Control.BackColor = Color.Salmon; } else { input.ErrorInput = false; bd.Control.BackColor = Color.WhiteSmoke; } } }