Answer the question
In order to leave comments, you need to log in
How to create a custom button in VB .NET?
I'm trying to create a custom button in VB .NET. Created this class:
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Public Class EllipseButton
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
Answer the question
In order to leave comments, you need to log in
Works, even embeds in the form.
#region License
// // Разработано: Коротенко Владимиром Николаевичем (Vladimir N. Korotenko)
// // email: [email protected]
// // skype:vladimir-korotenko
// // https://vkorotenko.ru
// // Создано: 06.04.2020 16:10
#endregion
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Kvn.CustomControls
{
public class EllipseButton : Button
{
protected override void OnPaint(PaintEventArgs e)
{
var grPath = new GraphicsPath();
grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
Region = new Region(grPath);
base.OnPaint(e);
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question