|
-
May 27th, 2011, 07:17 AM
#1
Thread Starter
New Member
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!
-
May 27th, 2011, 07:31 AM
#2
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.
-
May 27th, 2011, 07:55 AM
#3
Thread Starter
New Member
Re: TableLayoutPanel question.
 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!
-
May 27th, 2011, 08:48 AM
#4
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
-
May 27th, 2011, 08:50 AM
#5
Thread Starter
New Member
Re: TableLayoutPanel question.
 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!
-
May 27th, 2011, 06:11 PM
#6
Thread Starter
New Member
Re: TableLayoutPanel question.
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|