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)

public int CornerRadius { get; set; }

Property Value

Type: System.Int32

An Integer representing the radius. The default is 0, or no radius.

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.

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 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;
        // Increase the radius.
        rectangleShape1.CornerRadius = rectangleShape1.CornerRadius + 15;
Return to top