El siguiente codigo basicamente cambio el backcolor de los textbos de mi
formulario, el problema que tengo es que no me funciona y no se donde poder
llamar al evento para que se ejecute.
Sub SetupEventHandlers()
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox = True Then
AddHandler ctrl.GotFocus, AddressOf Controls_GotFocus
AddHandler ctrl.LostFocus, AddressOf Controls_LostFocus
End If
Next
End Sub
Private Sub Controls_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim ctrl As Control = CType(sender, Control)
ctrl.BackColor = Color.Yellow
End Sub
Private Sub Controls_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim ctrl As Control = CType(sender, Control)
ctrl.BackColor = Color.Yellow
End Sub
Leer las respuestas