How to keep a form from losing focus - VB.Net

If you want to keep a form from losing focus (i.e. options/preferences form) in your VB.Net program you can use the code below. This code was originally posted here

Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)

MyBase.OnLostFocus(e)

Me.Focus()

End Sub

Protected Overrides Sub OnDeactivate(ByVal e As System.EventArgs)

MyBase.OnDeactivate(e)

Me.Focus()

End Sub
Published: 2011-05-18
Updated: 2020-07-15
Category: Technology
Read Time: 0 minute(s)