ก่อนอื่นให้สร้าง Class 1 Class ขึ้นมาก่อน ผมใช้ชื่อว่า BigRadioButton โดยทำการสืบทอด Class หลักมาจาก RadioButton ครับ
Code (VB.NET)
Public Class BigRadioButton
Inherits RadioButton
Private m_buttonSize As Integer = 16
Private m_buttonLocation As Point = New Point(0, 0)
Public Property ButtonSize() As Integer
Get
Return m_buttonSize
End Get
Set(ByVal value As Integer)
m_buttonSize = value
Me.Invalidate()
End Set
End Property
Public Property ButtonLocation() As Point
Get
Return m_buttonLocation
End Get
Set(ByVal value As Point)
m_buttonLocation = value
Me.Invalidate()
End Set
End Property
Sub New()
MyBase.New()
End Sub
Protected Overrides Sub OnCheckedChanged(ByVal e As System.EventArgs)
MyBase.OnCheckedChanged(e)
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(pevent)
Dim rect As New Rectangle(m_buttonLocation.X, m_buttonLocation.Y, m_buttonSize, m_buttonSize)
If Me.Checked Then
ControlPaint.DrawRadioButton(pevent.Graphics, rect, ButtonState.Checked)
Else
ControlPaint.DrawRadioButton(pevent.Graphics, rect, ButtonState.Normal)
End If
End Sub
End Class