Ok, I asked this question and got excellent code example as answer. The code works but I don’t understand the meaning of the code. Can someone point the direction for me for further reading in order to understand the code. Here is the code that retrieves the checked radio button in a groupbox:
Dim rButton As RadioButton = GroupBox1.Controls _
.OfType(Of RadioButton)() _
.Where(Function(r) r.Checked = True) _
.FirstOrDefault()
Ok, the parts that I don’t understand are .OfType, .Where, .FirsrOrDefault
UPDATE:
Thanks guys, those things are LINQ
This code selects the first checked radio button in a group of buttons. Lets walk through the code:
Dim rButton As RadioButton = GroupBox1.Controls _Select the group of form controls
OfType(Of RadioButton)() _But only the Radio buttons from that group
Where(Function(r) r.Checked = True) _That are already checked
.FirstOrDefault()Return the first one or NULL if none are checked.