Reputation: 5146
Why is this event firing when the radiobutton gets loaded? Is there a way to prevent this? Code is as follows:
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(6, 19);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(75, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "You guess";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.groupBox1.Controls.Add(this.radioButton1);
public System.Windows.Forms.RadioButton radioButton1;
Upvotes: 0
Views: 1535
Reputation: 20180
The radio button's Checked
property defaults to false, but when it is added to a form and it is the only radio button, that value must change to true (at lease one radio button per group must be checked). You can prevent the event from firing by setting the Checked property for the radio button you want to be selected by default to true before you add it to the form (or subscribe to the changed event).
Upvotes: 2