IKComboBox.cs 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.ComponentModel;
  3. using System.Windows.Forms;
  4. namespace Infoking.Common.Windows.Control
  5. {
  6. public class IKComboBox : ComboBox
  7. {
  8. private Container components;
  9. public IKComboBox()
  10. {
  11. InitializeComponent();
  12. base.EnabledChanged += IKComboBox_EnabledChanged;
  13. }
  14. protected override void Dispose(bool disposing)
  15. {
  16. if (disposing && components != null)
  17. {
  18. components.Dispose();
  19. }
  20. base.Dispose(disposing);
  21. }
  22. private void InitializeComponent()
  23. {
  24. components = new System.ComponentModel.Container();
  25. }
  26. protected override void OnPaint(PaintEventArgs pe)
  27. {
  28. base.OnPaint(pe);
  29. }
  30. protected override void OnGotFocus(EventArgs e)
  31. {
  32. SelectAll();
  33. }
  34. protected override void OnLostFocus(EventArgs e)
  35. {
  36. Select(0, 0);
  37. }
  38. private void IKComboBox_EnabledChanged(object sender, EventArgs e)
  39. {
  40. base.TabStop = base.Enabled;
  41. }
  42. }
  43. }