On my forms I would like to change the background color of my controls when they receive focus, then restore it to the system color once focus is lost. The GotFocus portion works, but the LostFocus does not restore. Here is what I am using for code:
Dim holdColor as Color
Dim focusColor as Color = Color.PowderBlue
Private Sub txtName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.GotFocus
holdColor = Me.ActiveControl.BackColor
Me.ActiveControl.BackColor = focusColor
End Sub
Private Sub txtName_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.LostFocus
Me.ActiveControl.BackColor = holdColor
End Sub
Dim holdColor as Color
Dim focusColor as Color = Color.PowderBlue
Private Sub txtName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.GotFocus
holdColor = Me.ActiveControl.BackColor
Me.ActiveControl.BackColor = focusColor
End Sub
Private Sub txtName_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.LostFocus
Me.ActiveControl.BackColor = holdColor
End Sub