Results 1 to 6 of 6

Thread: TableLayoutPanel question.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    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!

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    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.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    Re: TableLayoutPanel question.

    Quote Originally Posted by Jenner View Post
    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!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: TableLayoutPanel question.

    Assuming .NET 3.5 or later, LINQ is your best buddy:
    vb.net Code:
    1. If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
    2.     'One of the RadioButton controls in TableLayoutPanel1 is checked.
    3. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    Re: TableLayoutPanel question.

    Quote Originally Posted by jmcilhinney View Post
    Assuming .NET 3.5 or later, LINQ is your best buddy:
    vb.net Code:
    1. If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
    2.     'One of the RadioButton controls in TableLayoutPanel1 is checked.
    3. End If
    Oh! I will try this later. I think I've been up too long writing this Time for some sleep.

    Thank you!

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    Re: TableLayoutPanel question.

    Quote Originally Posted by jmcilhinney View Post
    Assuming .NET 3.5 or later, LINQ is your best buddy:
    vb.net Code:
    1. If Me.TableLayoutPanel1.Controls.OfType(Of RadioButton)().Any(Function(rb) rb.Checked) Then
    2.     'One of the RadioButton controls in TableLayoutPanel1 is checked.
    3. 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
  •  



Click Here to Expand Forum to Full Width