I have several textboxes in a winform, some of them are inside a groupbox. I tried to loop over all textboxes in my form:
For Each c As Control In Me.Controls
If c.GetType Is GetType(TextBox) Then
' Do something
End If
Next
But it seemed to skip those inside the groupbox and loop only over the other textboxes of the form. So I added another For Each loop for the groupbox textboxes:
For Each c As Control In GroupBox1.Controls
If c.GetType Is GetType(TextBox) Then
' Do something
End If
Next
I wonder: is there a way to loop over all textboxes in a form–including those inside a groupbox–with a single For Each loop? Or any better/more elegant way to do it?
You can use this function, linq might be a more elegant way.