Today, I will teach you how to create rounded corners of a form using vb.net. This simple program illustrates how to remove the sharpen edges of the form and change it into an arc or circular edges. Follow the step by step guide to see how it works.
Open Microsoft Visual Studio 2015 and create a new windows form application.
Press F7 to open the code editor. In the code editor, create a method to create round corners of the form.
- Private Sub roundCorners(obj As Form)
- obj.FormBorderStyle = FormBorderStyle.None
- obj.BackColor = Color.Cyan
- Dim DGP As New Drawing2D.GraphicsPath
- 'top left corner
- DGP.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
- DGP.AddLine(40, 0, obj.Width - 40, 0)
- 'top right corner
- DGP.AddArc(New Rectangle(obj.Width - 40, 0, 40, 40), -90, 90)
- DGP.AddLine(obj.Width, 40, obj.Width, obj.Height - 40)
- 'buttom right corner
- DGP.AddArc(New Rectangle(obj.Width - 40, obj.Height - 40, 40, 40), 0, 90)
- DGP.AddLine(obj.Width - 40, obj.Height, 40, obj.Height)
- 'buttom left corner
- DGP.AddArc(New Rectangle(0, obj.Height - 40, 40, 40), 90, 90)
- obj.Region = New Region(DGP)
- End Sub
Do the following codes to execute the method in the first load of the form.
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
The complete source code is included. You can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.