2 Attachment(s)
Round the corners on a form or control
Attachment 191314
Attachment 191315
Code:
Public Class C_RoundCorners
Public Sub RoundCornersForm(Form As Form,
Optional Radius As Integer = 20)
'---------------------------------------------------------------------------------
' Round the corners on a form
'---------------------------------------------------------------------------------
Form.FormBorderStyle = FormBorderStyle.None
Dim DGP As New Drawing2D.GraphicsPath
DGP.StartFigure()
'** Top left corner
DGP.AddArc(New Rectangle(0, 0, Radius, Radius), 180, 90)
DGP.AddLine(Radius, 0, Form.Width - Radius, 0)
'** Top right corner
DGP.AddArc(New Rectangle(Form.Width - Radius, 0, Radius, Radius), -90, 90)
DGP.AddLine(Form.Width, Radius, Form.Width, Form.Height - Radius)
'** Bottom right corner
DGP.AddArc(New Rectangle(Form.Width - Radius, Form.Height - Radius, Radius, Radius), 0, 90)
DGP.AddLine(Form.Width - Radius, Form.Height, Radius, Form.Height)
'** Bottom left corner
DGP.AddArc(New Rectangle(0, Form.Height - Radius, Radius, Radius), 90, 90)
DGP.CloseFigure()
Form.Region = New Region(DGP)
End Sub
Public Sub RoundCornersControl(Control As Control,
Optional Radius As Integer = 5)
'---------------------------------------------------------------------------------
' Round the corners on a control
'---------------------------------------------------------------------------------
Dim DGP As New Drawing2D.GraphicsPath
DGP.StartFigure()
'** Top left corner
DGP.AddArc(New Rectangle(0, 0, Radius, Radius), 180, 90)
DGP.AddLine(Radius, 0, Control.Width - Radius, 0)
'** Top right corner
DGP.AddArc(New Rectangle(Control.Width - Radius, 0, Radius, Radius), -90, 90)
DGP.AddLine(Control.Width, Radius, Control.Width, Control.Height - Radius)
'** Bottom right corner
Dim brRadius As Integer = Radius + 5
DGP.AddArc(New Rectangle(Control.Width - brRadius, Control.Height - brRadius, brRadius, brRadius), 0, 90)
DGP.AddLine(Control.Width - brRadius, Control.Height, brRadius, Control.Height)
'** Bottom left corner
Dim blRadius As Integer = Radius + 3
DGP.AddArc(New Rectangle(0, Control.Height - blRadius, blRadius, blRadius), 90, 90)
DGP.CloseFigure()
Control.Region = New Region(DGP)
End Sub
End Class