Previous | Index | Next 

[INFO] GotFocus and LostFocus events in UserControls

UserControl classes converted by VB Migration Partner correctly receive and fire the GotFocus and LostFocus events, with the following minor differences:

  1. The VB6 UserControl class receives a GotFocus or LostFocus event only if the user control contains no child controls that can take the input focus. For example, if a VB6 user control contains a textbox, the UserControl class never receives this event: if the class contains a UserControl_GotFocus method, this method is never invoked. When the program is converted to VB.NET, the UserControl_GotFocus and UserControl_LostFocus methods inside the class are always invoked. 
  2. If a VB6 UserControl doesn’t contain any child control that can take the input focus but it has its CanGetFocus property set to True, then the user control can take the input focus and correctly fires GotFocus and LostFocus events inside the parent form. A converted user control, however, fires these two events only if it receives the focus only by means of the Tab key or a mouse click directly on the user control’s surface. In other words, if the end user clicks on a child control (that can’t take the focus), then no event is fired in the parent form.

 

Previous | Index | Next