我想以編程方式(當表單被加載時)從不同的組框中選擇我的RadioButton中的一個(只有一個單選按鈕需要從所有單選按鈕中檢查)。設置單選按鈕時檢查表單加載(VB網絡)?
我將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}
您的網格綁定到數據源嗎?你什麼時候將數據加載到網格中?你在哪個事件處理程序中執行你的發佈代碼? –