Share via


RectangleShape.CornerRadius Property

Gets or sets the radius for the corners of rounded rectangle and rounded square shapes.

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

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Property CornerRadius As Integer
    Get
    Set
[BrowsableAttribute(true)]
public int CornerRadius { get; set; }
[BrowsableAttribute(true)]
public:
property int CornerRadius {
    int get ();
    void set (int value);
}
[<BrowsableAttribute(true)>]
member CornerRadius : int with get, set
function get CornerRadius () : int
function set CornerRadius (value : int)

Property Value

Type: System.Int32
An Integer representing the radius. The default is 0, or no radius.

Remarks

The minimum value of CornerRadius is 0. This results in a rectangle or square without rounded corners. The maximum value is the height or width (whichever is smaller) of the RectangleShape divided by two. For a square shape this will create a circle.

Examples

The following example changes the CornerRadius of a RectangleShape when the RectangleShape is clicked. This example requires that you have a RectangleShape named RectangleShape1 on a form.

Private Sub RectangleShape1_Click(ByVal sender As System.Object,
 ByVal e As System.EventArgs) Handles RectangleShape1.Click
    Dim max As Integer
    ' Calculate the maximum radius.
    max = Math.Min(RectangleShape1.Height, RectangleShape1.Width) / 2
    ' Check whether the maximum radius has been reached.
    If RectangleShape1.CornerRadius = max Then
        ' Reset the radius to 0.
        RectangleShape1.CornerRadius = 0
    Else
        ' Increase the radius.
        RectangleShape1.CornerRadius =
          RectangleShape1.CornerRadius + 15
    End If
End Sub
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
    int max;
    // Calculate the maximum radius.
    max = Math.Min(rectangleShape1.Height, rectangleShape1.Width) / 2;
    // Check whether the maximum radius has been reached.
    if (rectangleShape1.CornerRadius == max)
    // Reset the radius to 0.
    {
        rectangleShape1.CornerRadius = 0;
    }
    else
    {
        // Increase the radius.
        rectangleShape1.CornerRadius = rectangleShape1.CornerRadius + 15;
    }
}

.NET Framework Security

See Also

Reference

RectangleShape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the Line and Shape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)