I need to change the background color of the current control to make it easier for users to see where they are on complex forms. I'm calling the following Sub from both the GotFocus and LostFocus events to turn background color on and off, and when turning on, I want to select all text in the control. Background color changes are working perfectly, but SelectAll doesn't work. Here's the Sub:
Public Sub P_Focus(ByRef sender As Object, ByVal Focus As Boolean)
Static Dim lBackColor As Color
Select Case True
Case TypeOf sender Is TextBox
Dim obj As TextBox = DirectCast(sender, TextBox)
If Focus = True Then
lBackColor = obj.BackColor
obj.BackColor = Color.FromArgb(255, 255, 192)
obj.SelectAll()
Else
obj.BackColor = lBackColor
End If
End Select
End Sub
I eliminated all but the TextBox case for brevity.
Can anyone help?