2011-07-03 100 views
0

爲什麼在單選按鈕被加載時該事件觸發?有沒有辦法來防止這種情況?代碼如下:radiobutton checkedchange事件在加載時觸發

 // 
     // 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; 
+0

請提供一個示例代碼,以及與按鈕進行交互的所有點。 – DanNsk

+0

@DanNsk見上面。 – soandos

回答

2

單選按鈕的Checked屬性默認爲false,但是當它被添加到形式,它是唯一的單選按鈕,則該值必須改變爲真(以每租用一個單選按鈕組必須被檢查)。您可以通過將默認選中的單選按鈕的Checked屬性設置爲true,然後將其添加到表單中(或訂閱更改的事件),來防止事件觸發。

相關問題