摘要: 1 public class TextBoxInt : TextBox 2 { 3 public TextBoxInt() 4 { 5 KeyDown += TextBoxInt_KeyDown; 6 TextChanged += TextBoxInt_TextChanged; 7 } 8 9 private void TextBoxInt_TextChanged(object sender, TextChangedEventArgs e)10 {... 阅读全文
posted @ 2013-12-03 13:29 CandyZkn 阅读(1216) 评论(0) 推荐(0) 编辑
摘要: 1 /// 2 /// 使用正则表达式限制输入 3 /// 4 public class TextBoxRegex : TextBox 5 { 6 // 正则表达式,只含有汉字、数字、字母、下划线不能以数字开头 7 private const string NamimgPattern = "^(?![0-9])[a-zA-Z0-9_\u4e00-\u9fa5]{1,30}$"; 8 9 public TextBoxRegex()10 {11 TextCha... 阅读全文
posted @ 2013-12-03 12:14 CandyZkn 阅读(1818) 评论(0) 推荐(0) 编辑
摘要: 一个将数字转成字母的方法 1 private static string Num_to_letter(int value) 2 { 3 //此处判断输入的是否是正整数数字 4 if (Regex.IsMatch(value.ToString(), "^\\d+$")) 5 { 6 int remainder = value % 26; 7 //remainder = (remainder == 0) ? 26 : remaind... 阅读全文
posted @ 2013-12-02 18:20 CandyZkn 阅读(1023) 评论(0) 推荐(0) 编辑
摘要: 一个字母转成数字的小方法,写的挺精简的,值得借鉴! 1 private static int Letter_to_num(string str) 2 { 3 str = str.ToUpper(); 4 int len = str.Length; 5 int index = 0; 6 for (var i = 0; i < len; i++) 7 { 8 var ch = str[i]; 9 ... 阅读全文
posted @ 2013-12-02 18:15 CandyZkn 阅读(1079) 评论(0) 推荐(0) 编辑