Lost focus

  • Thread starter Thread starter Philipp
  • Start date Start date
P

Philipp

Hi NG,

Is there a way to know which control just lost focus when clicking on a
button?
(other than keeping an object variable which is set when a control loses
focus)?

Thanks in advance!

Greets
Philipp
 
Philipp said:
Is there a way to know which control just lost focus when clicking on a
button?

I've used this in a custom Button class.

Class myButton
Inherits Button

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

If Not (Me.FindForm Is Nothing) _
AndAlso Not (Me.FindForm.ActiveControl Is Me) _
Then
Me.Focus()
End If

MyBase.OnClick()

End Sub

End Class

I haven't tried, but you /might/ be able to do the same sort of thing in
the event handler for an "ordinary" Button's Click event.

HTH,
Phill W.
 
Back
Top