我想以编程方式(在加载表单时)从不同的Group Box中选择一个RadioButton(只需要从所有单选按钮检查一个单选按钮)。
我将datagridview值加载到变量。 现在,我想选择与变量中的值对应的单选按钮。
我尝试使用else的简单代码if和select case。但两者都不起作用?
{ Dim SpecimenName As String = frmMain.DataGridView1.Rows(0).Cells(4).Value.ToString
If SpecimenName = "" Then
'RadioButton1.AutoCheck()
ElseIf SpecimenName Like "Michanical" Then
RadioButton1.PerformClick()
ElseIf SpecimenName Like "Manage" Then
RadioButton2.PerformClick()
ElseIf SpecimenName Like "Civil" Then
RadioButton3.Checked = True
ElseIf SpecimenName Like "Electronics" Then
RadioButton4.Checked = True
ElseIf SpecimenName Like "Supply" Then
RadioButton5.Checked = True
ElseIf SpecimenName Like "Landscaping" Then
RadioButton6.Checked = True
ElseIf SpecimenName Like "P&D" Or SpecimenName Like "Project" Then
RadioButton7.Checked = True
End If}
答案 0 :(得分:0)
在RadioButton1.Checked = True
事件中设置Form_Shown
。
Form_Load
将无效。