Something else must be going on to make the panel not shown. In the attach VS2008 project you get to select a radiobutton selection from a choice of three using two methods, one with a language extension while the other does the same thing simply inline code.
In short using your code or the following will not make a form panel disappear
Code:
Dim RB = (From Item In (From Control In Panel1.Controls _
Where TypeOf Control Is RadioButton _
Select Control).Cast(Of RadioButton)() _
Where Item.Checked _
Select Item).DefaultIfEmpty(New RadioButton).First
If RB.Name = String.Empty Then
MsgBox("No card selected")
Else
MsgBox(String.Format("Pay with [{0}]", RB.Text))
ReSetPanelRadioButtons()
Same as above but in an extension
Code:
<System.Diagnostics.DebuggerStepThrough()> _
<System.Runtime.CompilerServices.Extension()> _
Public Function SelectedRadioButton(ByVal container As Control) As RadioButton
Return (From Item In (From Control In container.Controls _
Where TypeOf Control Is RadioButton _
Select Control).Cast(Of RadioButton)() _
Where Item.Checked _
Select Item).DefaultIfEmpty(New RadioButton).First
End Function
And the following mimics TryParse
Code:
<System.Diagnostics.DebuggerStepThrough()> _
<System.Runtime.CompilerServices.Extension()> _
Public Function Get_SelectedRadioButton(ByVal container As Control, _
ByRef Button As RadioButton) As Boolean
Dim Result As Boolean = False
Dim RadioCollection = From Control In container.Controls _
Where TypeOf Control Is RadioButton Select Control
If Not RadioCollection Is Nothing Then
Dim CheckedButton = (From Item In RadioCollection.Cast(Of RadioButton)() _
Where Item.Checked).DefaultIfEmpty(Button).First
If Not CheckedButton.Name.Equals(Button.Name) Then
Button = CheckedButton
Result = True
End If
End If
Return Result
End Function