Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27153

VS 2010 Changing and Restoring Background Color

$
0
0
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

Viewing all articles
Browse latest Browse all 27153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>