How to Create Rounded Corners of a Form Using VB.Net

Submitted by: 
Visitors have accessed this post 320 times.

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.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application.
figure 1

Step 2

Press F7 to open the code editor. In the code editor, create a method to create round corners of the form.

  1.  
  2. Private Sub roundCorners(obj As Form)
  3.  
  4. obj.FormBorderStyle = FormBorderStyle.None
  5. obj.BackColor = Color.Cyan
  6.  
  7.  
  8. Dim DGP As New Drawing2D.GraphicsPath
  9. DGP.StartFigure()
  10. 'top left corner
  11. DGP.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
  12. DGP.AddLine(40, 0, obj.Width - 40, 0)
  13.  
  14. 'top right corner
  15. DGP.AddArc(New Rectangle(obj.Width - 40, 0, 40, 40), -90, 90)
  16. DGP.AddLine(obj.Width, 40, obj.Width, obj.Height - 40)
  17.  
  18. 'buttom right corner
  19. DGP.AddArc(New Rectangle(obj.Width - 40, obj.Height - 40, 40, 40), 0, 90)
  20. DGP.AddLine(obj.Width - 40, obj.Height, 40, obj.Height)
  21.  
  22. 'buttom left corner
  23. DGP.AddArc(New Rectangle(0, obj.Height - 40, 40, 40), 90, 90)
  24. DGP.CloseFigure()
  25.  
  26. obj.Region = New Region(DGP)
  27.  
  28.  
  29. End Sub

Step 3

Do the following codes to execute the method in the first load of the form.

  1.  
  2. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  3. roundCorners(Me)
  4. 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.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.