I’ve created a WinForms User Control. I read a couple of places something about GotFocus() and LostFocus() events, yet my user control doesn’t provide these events in the Events part of the Properties window.
I even tried typing override to see if these event handlers would come up but they don’t. I can’t find them anywhere.
So I created my own methods with these names, and then I get the following error:
Warning 1 ‘mynamespace.mycontrol.GotFocus()’ hides inherited member ‘System.Windows.Forms.Control.GotFocus’. Use the new keyword if hiding was intended.
What the heck is going on here. If GotFocus() already exists, why can’t I find it and use it?
It looks like from the MSDN Documentation that they are there inherited from Control, but are not encouraged to be used. They want you to use the Enter and Leave Events.
That said you can get access to them as User1718294 suggested with the += or you can Override the
OnGotFocusandOnLostFocusEvent.