Shape.GotFocus Event

 

Occurs when the shape receives focus.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

[BrowsableAttribute(false)]
public event EventHandler GotFocus

When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), or by calling the Select or M:Microsoft.VisualBasic.PowerPacks.Shape.SelectNextControl(Microsoft.VisualBasic.PowerPacks.Shape,System.Boolean,System.Boolean,System.Boolean,System.Boolean) method, focus events occur in the following order:

Enter 

GotFocus

Leave 

LostFocus 

When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

Enter 

GotFocus

LostFocus 

Leave 

For more information about how to handle events, see Handling and Raising Events.

System_CAPS_noteNote

Do not try to set focus in the LostFocus event handler. Doing so can cause your application or the operating system to stop responding.

The following example shows how to respond to the GotFocus event in an event handler. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

private void rectangleShape1_GotFocus(object sender, System.EventArgs e)
{
    rectangleShape1.SelectionColor = Color.Red;
}
Return to top
Show: