TxtZipCode.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace Dongke.WinForm.Controls
  6. {
  7. /// <summary>
  8. /// 邮编输入文本框
  9. /// </summary>
  10. [ToolboxBitmap(typeof(TextBox))]
  11. public class TxtZipCode : TextBoxCodeBase
  12. {
  13. #region 构造函数
  14. /// <summary>
  15. /// 邮编输入文本框
  16. /// </summary>
  17. public TxtZipCode()
  18. {
  19. this.Rejected = "[^0-9]";
  20. this.Regular = @"^[1-9]\d{5}$";
  21. this.MaxLength = 6;
  22. }
  23. #endregion
  24. #region 重写属性
  25. /// <summary>
  26. /// 获取或设置用户可在文本框控件中键入或粘贴的最大字符数。
  27. /// </summary>
  28. [Browsable(false)]
  29. [EditorBrowsable(EditorBrowsableState.Never)]
  30. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  31. public override int MaxLength
  32. {
  33. get
  34. {
  35. return base.MaxLength;
  36. }
  37. set
  38. {
  39. base.MaxLength = value;
  40. }
  41. }
  42. /// <summary>
  43. /// 获取或设置允许输入的最小长度。
  44. /// </summary>
  45. [Browsable(false)]
  46. [EditorBrowsable(EditorBrowsableState.Never)]
  47. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  48. public override int MinLength
  49. {
  50. get
  51. {
  52. return base.MinLength;
  53. }
  54. set
  55. {
  56. base.MinLength = value;
  57. }
  58. }
  59. #endregion
  60. }
  61. }