35 lines
922 B
VB.net
35 lines
922 B
VB.net
Imports System.Windows.Forms
|
|
|
|
Public Class MyRadioButton
|
|
Inherits System.Windows.Forms.RadioButton
|
|
|
|
Public Sub New()
|
|
End Sub
|
|
|
|
Public Property GroupName As String
|
|
|
|
|
|
Private Sub MyRadioButton_Click(sender As Object, e As EventArgs) Handles Me.Click
|
|
' Dim rb As MyRadioButton = DirectCast(sender, MyRadioButton)
|
|
' MsgBox(Me.Checked)
|
|
' If Not Me.Checked Then
|
|
uncheck(Me.FindForm, Me.GroupName)
|
|
Me.Checked = True
|
|
' End If
|
|
|
|
|
|
End Sub
|
|
|
|
Sub uncheck(c As Control, GroupName As String)
|
|
' MsgBox(c.GetType.Name)
|
|
If c.GetType.Name = "MyRadioButton" AndAlso DirectCast(c, MyRadioButton).GroupName = GroupName Then
|
|
DirectCast(c, MyRadioButton).Checked = False
|
|
ElseIf c.HasChildren Then
|
|
For Each csub In c.Controls
|
|
uncheck(csub, GroupName)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|