Dim str As String =e.Form.Controls("cplx").Value '控件1值
Dim str1 As String '控件2名称
Dim str2 As String '控件2值
Dim str3 As String '控件3名称
For Each ctl As WinForm.Control In e.Form.Controls '遍历所有控件
If TypeOf ctl Is WinForm.ComboBox Then
str1 = e.Form.Controls(ctl.Name) '
str2= e.Form.Controls(str1).Value '效果:
str3 = "dw"&Right(str1,1) ' 控件2名称=”fjmc1” 有1-20个 对应 控件3名称=”dw1”有1-20个
If str2 = Nothing Then '控件2值为空,那么控件3值为空
e.Form.Controls(str3).value = Nothing '效果:控件3值为空
Else
e.Form.Controls(str3).value =DataTables("字典").Find(str&"_辅件_名称" = str2,str&"_辅件_单位") '控件3值 '
'查找字典表 str&"_辅件_名称" 列 对应 str&"_辅件_单位"的数据
End If
End If
Next
'整体思路,当控件2选择后,根据其值不同在控件3中自动填入字典表的对应单位,目前的问题就是控件3赋值,代码写不好