Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7708311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:34:48+00:00 2026-06-01T00:34:48+00:00

I have a form that is dynamically created, on this form are several radio

  • 0

I have a form that is dynamically created, on this form are several radio buttons that are created at runtime. There is a button on this form eg “Next” when the user clicks on the next I want to loop through and check if one of the radio buttons are checked before I continue, I have tried the following:

    void nextButton_Click(object sender, EventArgs e)
    {
        foreach (Control c in _form.Controls)
        {
            if (c is RadioButton)
            {
                RadioButton radio = c as RadioButton;

                if (radio is RadioButton)
                {
                    if (radio.Checked == true)
                    {
                        //code continue to next 
                    }
                    else
                    {
                        MessageBox.Show("You must select at least one.");
                    }
                }

            }
        } 
    }

Kind regards
geo

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:34:49+00:00Added an answer on June 1, 2026 at 12:34 am

    You can use Linq to make it simpler

    bool checked = _form.Controls.OfType<RadioButton>().Any(rb => rb.Checked);
    

    –EDIT–

    I updated the answer to recursively search all controls.

    bool IsChecked(Control parent)
    {
        if (parent.Controls.OfType<RadioButton>().Any(rb => rb.Checked)) return true;
    
        foreach (Control c in parent.Controls)
            if (IsChecked(c)) return true;
    
        return false;
    }
    
    bool checked = IsChecked(_form);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several radio buttons that are dynamically populated on a form and I
I have a form that is dynamically created. It is a winForms application. This
i have a few select fields that are dynamically created by the end user
I have a several form elements that I am dynamically creating with javascript when
I have created a form that displays values in plain displayfields. There is an
Using CakePHP 1.3 , I have a (working) form that has dynamically created form
I have a form field (a series of checkboxes) that's being created dynamically from
I have a dynamic form that allow to add many fields dynamically, I Know
I have a Winforms application that dynamically instantiates external form objects for use in
I have a Greasemonkey script that dynamically inserts an HTML form into some web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.