ComBoxWithFocus.cs 807 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace UAS_MES_NEW.CustomControl.ComBoxWithFocus
  11. {
  12. public partial class ComBoxWithFocus : ComboBox
  13. {
  14. public ComBoxWithFocus()
  15. {
  16. InitializeComponent();
  17. this.Enter += this.ComBoxWithFocus_Enter;
  18. this.Leave += this.ComBoxWithFocus_Leave;
  19. }
  20. private void ComBoxWithFocus_Enter(object sender, EventArgs e)
  21. {
  22. this.BackColor = Color.GreenYellow;
  23. }
  24. private void ComBoxWithFocus_Leave(object sender, EventArgs e)
  25. {
  26. this.BackColor = Color.White;
  27. }
  28. }
  29. }