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

  • SEARCH
  • Home
  • 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 7439567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:43:29+00:00 2026-05-29T10:43:29+00:00

I have a win form, on which there are several radionbuttons and labels and

  • 0

I have a win form, on which there are several radionbuttons and labels and some other controls wich I am generating at run time. Not what I want when I check a radiobutton, all the radionbutton should be unchecked except the one I checked. This applies to every radiobutton. In short, I want one radionbutton checked at a time.

 private RadioButton GenerateRadioButton(string id)
        {
            RadioButton _radioButton = new RadioButton();
            _radioButton.Location = new Point(32, 20);
            _radioButton.Margin = new Padding(4, 4, 4, 4);
            _radioButton.Size = new Size(130, 36);
            _radioButton.Name = id;
            _radioButton.AutoSize = true;
            _radioButton.Font = new Font("Arial", 16, FontStyle.Bold);
            _radioButton.CheckedChanged += new System.EventHandler(RadioButton_CheckedChanged);
            return _radioButton;
        }

  private void RadioButton_CheckedChanged(object sender, EventArgs e)
        {
          HandleRadioButtinClick(((RadioButton)sender).Name);
            ((RadioButton)sender).Checked = true;
        }

     private void HandleRadioButtinClick(string ctrlId)
            {
                FrmSpace objFrmSpace = new FrmSpace();
                foreach (Control ctrl in pictureBox1.Controls)
                {
                    if (ctrl is Panel)
                    {
                        foreach (Control ctl in ctrl.Controls)
                        {
                            if (ctl is RadioButton && ctl.Name != ctrlId)
                                ((RadioButton)ctl).Checked = false;
                        }
                    }
                }
            }

Here is the code above. The problem with this code is that, when I check a radiobutton, if there is any other radiobutton that is checked, and I try to uncheck it, its checkedchanged event is also fired, that causes all the radiobutton unchecked again. I hope I am clear what I want to convey.

Please provide some solution.

Thanks

  • 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-05-29T10:43:29+00:00Added an answer on May 29, 2026 at 10:43 am

    Have you tried using a groupbox for all of the radiobuttons? This is the default function you are asking for.

    EDIT : to clarify your questions

            // some function
            GroupBox g = createGBox();
            this.Controls.Add(g);
            g.Controls.Add(radioButton1);
            g.Controls.Add(radioButton2);
        }
    
        public GroupBox createGBox()
        {
            GroupBox gBox = new GroupBox();
            gBox.Location = new System.Drawing.Point(72, 105);
            gBox.Name = "BOX";
            gBox.Size = new System.Drawing.Size(200, 100);
            gBox.Text = "This is a group box";
            return gBox;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There
I have a c# (win form) visual studio project which i am now compiling
I have a winform form which has typical OK and Cancel buttons. The OK
I have a windows installer project which installs some software (winform, service, mce addin).
I have a Windows form App which write to log files using log4net. The
I have a WinForm application which is generating CSV files. I give the user
I have a C# winform app which is doing a lot of calculation. there
I have a win app form with 3 text boxes and buttons as dial
i have a winform application in which i have a lot of controls that
I have a win form UI that looks like a typical calculator. Naturally I

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.