Share via


Shape.Focus Method ()

 

Sets input focus to a line or shape control.

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

Syntax

public bool Focus()
public:
bool Focus()
member Focus : unit -> bool
Public Function Focus As Boolean

Return Value

Type: System.Boolean

true if the input focus request was successful; otherwise, false.

Remarks

The Focus method returns true if the control successfully received input focus. A control can be selected and receive input focus if all the following are true: the control is visible and enabled, it is contained in another control, and all its parent controls are both visible and enabled.

Note

Focus is a low-level method intended primarily for custom control authors. Developers should use the Select method or the ActiveControl property for child controls.

Examples

The following example sets the focus to the specified Shape, if it can receive focus.

public void ShapeSetFocus(Microsoft.VisualBasic.PowerPacks.Shape shape)
{
    // Set focus to the control, if it can receive focus.
    if (shape.CanFocus)
    {
        shape.Focus();
    }
}
Public Sub ShapeSetFocus(ByVal shape As Microsoft.VisualBasic.PowerPacks.Shape)
    ' Set focus to the control, if it can receive focus.
    If shape.CanFocus Then
        shape.Focus()
    End If
End Sub

See Also

Shape Class
Microsoft.VisualBasic.PowerPacks Namespace
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)
Introduction to the Line and Shape Controls (Visual Studio)

Return to top