TableLayoutPanel question.
I'm curious if there is a "check all" kind of thing for a tablelayoutpanel?
To explain, say I have TableLayoutPanel1 with 6 radio buttons and I'm doing an error check to make sure that at least one radio button has been selected during a click event. Do I have to do If / and with all 6 radio buttons? Or is there something like "If TableLayoutPanel1.checked(obviously not this) = false then"
Any help is greatly appreciated!
Re: TableLayoutPanel question.
No, TableLayoutPanels are just simple layout controls. Your best way would be to loop through the .Controls collection and check that way. It's much easier and far less typing than a half-dozen "If Then" statements.
Re: TableLayoutPanel question.
Quote:
Originally Posted by
Jenner
No, TableLayoutPanels are just simple layout controls. Your best way would be to loop through the .Controls collection and check that way. It's much easier and far less typing than a half-dozen "If Then" statements.
Excellent. I'm not completely familiar with accessing the controls (row,column) so I'll be reading up.
This is much more efficient for sure.
Thank you!
Re: TableLayoutPanel question.
Assuming .NET 3.5 or later, LINQ is your best buddy:
vb.net Code:
If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
'One of the RadioButton controls in TableLayoutPanel1 is checked.
End If
Re: TableLayoutPanel question.
Quote:
Originally Posted by
jmcilhinney
Assuming .NET 3.5 or later, LINQ is your best buddy:
vb.net Code:
If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
'One of the RadioButton controls in TableLayoutPanel1 is checked.
End If
Oh! I will try this later. I think I've been up too long writing this ;) Time for some sleep.
Thank you!
Re: TableLayoutPanel question.
Quote:
Originally Posted by
jmcilhinney
Assuming .NET 3.5 or later, LINQ is your best buddy:
vb.net Code:
If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
'One of the RadioButton controls in TableLayoutPanel1 is checked.
End If
This is exactly what I was looking for. Thank you so much.