private void bd_ParseStr(object sender, ConvertEventArgs e) { string s = e.Value as string; Binding binding = sender as Binding; InputRangeStr str2 = this.inputrange_str[0]; if (str2 != null) { if (Encoding.GetEncoding("GB2312").GetByteCount(s) > str2.BytesCount) { str2.ErrorInput = true; binding.Control.BackColor = Color.Salmon; } else { str2.ErrorInput = false; binding.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; } } }