Imports System.Drawing.Drawing2D
Imports System.Drawing
Public Class Form3
Private Sub Form3_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load
Dim path As GraphicsPath = GetRoundedRectPath(Me.ClientRectangle,20)
Me.Region = New Region(path)
End Sub
Private Function GetRoundedRectPath(ByVal Rectangle As Rectangle,ByVal r As Integer) As GraphicsPath
Rectangle.Offset(-1,-1)
Dim RoundRect As New Rectangle(Rectangle.Location,New Size(r - 1,r - 1))
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect,180,90) '左上角
RoundRect.X = Rectangle.Right - r '右上角
path.AddArc(RoundRect,270,90)
RoundRect.Y = Rectangle.Bottom - r '右下角
path.AddArc(RoundRect,90)
RoundRect.X = Rectangle.Left '左下角
path.AddArc(RoundRect,90,90)
path.CloseFigure()
Return path
End Function
End Class