NumericUpDownEx.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. namespace LYFZ.ComponentLibrary
  8. {
  9. public partial class NumericUpDownEx : LYFZ.OtherExpansion.SkinControl.SkinNumericUpDown//System.Windows.Forms.NumericUpDown
  10. {
  11. public NumericUpDownEx()
  12. {
  13. InitializeComponent();
  14. this.KeyUp += NumericUpDownEx_KeyUp;
  15. }
  16. void NumericUpDownEx_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
  17. {
  18. if (e.KeyCode == System.Windows.Forms.Keys.Delete || e.KeyCode == System.Windows.Forms.Keys.Back)
  19. {
  20. try
  21. {
  22. if (this.Text.Trim().Length <= 0)
  23. {
  24. this.Text = "0";
  25. this.Value = 0;
  26. }
  27. }
  28. catch
  29. {
  30. this.Text = this.Minimum.ToString();
  31. this.Value = this.Minimum;
  32. }
  33. }
  34. }
  35. public NumericUpDownEx(IContainer container)
  36. {
  37. container.Add(this);
  38. this.KeyUp += NumericUpDownEx_KeyUp;
  39. }
  40. }
  41. }