Saturday, May 23, 2020

How to Create a Round Button in VB.Net

Hi, now I am discuss how we create a Circle shape Or Round shape Button in VB.Net
First we create a Class named CircleButton. Now paste the below code and use it in VB forms.

Imports System.Drawing.Drawing2D

Public Class CircleButton

    Inherits Button

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

        Dim grPath As GraphicsPath = New GraphicsPath()

        grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height)

        Me.Region = New Region(grPath)

        MyBase.OnPaint(e)

    End Sub

End Class


If there is any other better option,
Please share it here or mail to me arkaa4@gmail.com

Thank You,
Arka Gupta.

No comments:

Post a Comment