我正在創建基於電子郵件計數的單選按鈕,當表單打開時,用戶將檢查單選按鈕,然後該emailId動態存儲在配置文件中。前景添加在如何在vb.net中動態檢查單選按鈕
當outlook將關閉,並再次打開,然後我從Config文件中獲取最後選擇的郵件ID並存儲在字符串中,但我無法檢查該特定的emailID我從配置中獲取,因爲單選按鈕我已經動態創建。每當表格將打開我想檢查最後選定的radioButton,即使我關閉了前景也一次又一次我打開我需要檢查最後選定的單選按鈕。
這是我的動態創建的單選按鈕
For Each email As String In Arremailslist
Dim rb As New RadioButton
rb.Name = email
rb.Text = email
rb.AutoSize = True
dynamictablelayout.SetColumn(rb, 0)
dynamictablelayout.SetRow(rb, i)
dynamictablelayout.Controls.Add(rb)
i = i + 1
Next
這種方法,我在Form_Load事件
調用這是在配置文件
覈對,對於我的按鈕的Click事件代碼,電子郵件ID檢查和更新Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
selectedmailID = Nothing
For Each c As Control In dynamictablelayout.Controls
If c.GetType Is GetType(RadioButton) Then
Dim rb As RadioButton = DirectCast(c, RadioButton)
If rb.Checked Then
selectedmailID = rb.Text
updateconfige(selectedmailID)
Exit For
End If
End If
Next
Me.Close()
End Sub
你想在哪裏檢查單選按鈕? – Sathish