1. Public Sub New()
2. InitializeComponent()
3.
4. For Each control As Control In Me.Controls
5. Dim ctrlCurrent As TextBox = TryCast(control, TextBox)
6. AddHandler ctrlCurrent.GotFocus, AddressOf ctrlCurrent_GotFocus
7. AddHandler ctrlCurrent.LostFocus, AddressOf ctrlCurrent_LostFocus
8. Next
9. End Sub
10.
11. Private Sub ctrlCurrent_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
12. TryCast(sender, Control).BackColor = Color.White
13. End Sub
14.
15. Private Sub ctrlCurrent_GotFocus(ByVal sender As Object, ByVal e As EventArgs)
16.
17. TryCast(sender, Control).BackColor = Color.GreenYellow
18. End Sub