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

'Declaration
Public Function Focus As Boolean
public bool Focus()
public:
bool Focus()
member Focus : unit -> bool 
public function Focus() : 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 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
public void ShapeSetFocus(Microsoft.VisualBasic.PowerPacks.Shape shape)
{
    // Set focus to the control, if it can receive focus.
    if (shape.CanFocus)
    {
        shape.Focus();
    }
}

.NET Framework Security

See Also

Reference

Shape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

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)