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

I enjoy sharing the content that you find here. I ask that you consider purchasing an item on my Amazon Wish List or you can make a donation.

Back To Top