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
Updated: 2020-07-15 | Posted: 2011-05-18