我在Visual Basic
中编写了一个代码(使用visual studio 2010),现在我遇到了这个问题:
我在表单中添加了3 RadioButtons
,我选择了一个按钮并以另一种形式(应用程序有多种形式)。
问题是,当我以第一种形式返回时,包含RadioButtons
(意思是,关闭当前表单并显示该表单),我选择的按钮不再被选中,我想保持选中状态。这有什么问题?我该怎么办?
答案 0 :(得分:0)
你可以使用my.settings。 进行名为“难度”的设置
在表单加载时检查您存储的内容。
喜欢这个。
Private Sub Form1_Load(sender as Object,e As EventArgs)处理MyBase.Load
If My.Settings.Difficulty = "Easy" Then
RadioButton1.Checked = True
ElseIf My.Settings.Difficulty = "Hard" Then
RadioButton2.Checked = True
ElseIf My.Settings.Difficulty = "Unreal" Then
RadioButton3.Checked = True
End If
End Sub
Private Sub RadioButton1_MouseClick(sender As Object, e As MouseEventArgs) Handles RadioButton1.MouseClick
My.Settings.Difficulty = "Easy"
RadioButton2.Checked = False
RadioButton3.Checked = False
My.Settings.Save()
End Sub
Private Sub RadioButton2_MouseClick(sender As Object, e As MouseEventArgs) Handles RadioButton2.MouseClick
My.Settings.Difficulty = "Hard"
RadioButton1.Checked = False
RadioButton3.Checked = False
My.Settings.Save()
End Sub
Private Sub RadioButton3_MouseClick(sender As Object, e As MouseEventArgs) Handles RadioButton3.MouseClick
My.Settings.Difficulty = "Unreal"
RadioButton1.Checked = False
RadioButton2.Checked = False
My.Settings.Save()
End Sub