Fills the inside of a rectangle with rounded corners.
Syntax

[C#]

void FillRoundRectangle(Brush brush, RectangleF rect, SizeF cornerRadius);
void FillRoundRectangle(Pen pen, RectangleF rect, SizeF cornerRadius);

[Visual Basic]

Sub FillRoundRectangle(brush As Brush, rect As RectangleF, cornerRadius As SizeF)
Sub FillRoundRectangle(pen As Pen, rect As RectangleF, cornerRadius As SizeF)
Params
Name Description
brush The brush to use for the fill.
rect The rectangle to be filled.
cornerRadius The horizontal and vertical radii for rounded corners.
pen The pen to use for drawing the rectangle.
Notes

None.

Example

Here we paint a blue rounded rectangle on the bitmap, which is auto sized. We also set the size of the corners to 32 pixels - the default is 16.

Note that the bitmap size is set to 250x250 because we center the image (25 + 200 + 25 = 250). Size the bitmap manually if this is not what you want.

[C#]using (Bitmap bm = new Bitmap(500, 500)) {
  using (Graphics gr = Graphics.FromImage(bm))
    gr.FillRoundRectangle(Brushes.Blue, new RectangleF(50, 50, 400, 400), new SizeF(64, 64));
  bm.Save(Server.MapPath("IG8_Graphics_FillRoundRectangle.png"));
}



IG8_Graphics_FillRoundRectangle.png