title: Prevent radiobutton click
body: <p>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.</p>
  
  <pre><code> 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 &amp;&amp; ctl.Name != ctrlId)
                                  ((RadioButton)ctl).Checked = false;
                          }
                      }
                  }
              }
  </code></pre>
  
  <p>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.</p>
  
  <p>Please provide some solution.</p>
  
  <p>Thanks</p>