代码应该没有问题,我只是在窗口中,设立了一个combobwox,在窗口事件中写下:DataTables("快递寄表").loadDim sjgs As WinForm.ComboBox = e.Form.Controls("ComboBox4")
sjgs.ComboList = DataTables("客户").GetComboListString("客户名称")
Dim sjr As WinForm.ComboBox = e.Form.Controls("ComboBox5")
sjr.ComboList = DataTables("客户联系人").GetComboListString("姓名")
Dim jjgs As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim jjlxr As WinForm.ComboBox = e.Form.Controls("ComboBox3")
jjgs.ComboList =DataTables("公司名称表").GetComboListString("公司名称")
jjlxr.ComboList = DataTables("员工").GetComboListString("姓名")
Dim sjgygs As WinForm.ComboBox = e.Form.Controls("ComboBox6")
sjgygs.ComboList = DataTables("供应商").GetComboListString("供应名称")
Dim jjgsg As WinForm.ComboBox = e.Form.Controls("ComboBox9")
Dim lxrg As WinForm.ComboBox = e.Form.Controls("ComboBox10")
Dim sjlxrg As WinForm.ComboBox = e.Form.Controls("ComboBox8")
jjgsg.ComboList = DataTables("公司名称表").GetComboListString("公司名称")
lxrg.ComboList = DataTables("员工").GetComboListString("姓名")
在表事件中写下:
If e.DataCol.Name = "收件公司名称" Then '发生变化的是产品编号吗?
'在产品表找出该产品
Dim dr As DataRow
Dim pr As DataRow
dr = DataTables("客户").Find("客户名称 = '" & e.DataRow("收件公司名称") & "'" )
If dr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("收件公司地址")= dr("地址")
e.DataRow("客户型") = True
End If
pr = DataTables("供应商").Find("供应名称 = '" & e.DataRow("收件公司名称") & "'" )
If pr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("收件公司地址")= pr("供应商地址")
e.DataRow("收件联系人") = pr("联系人")
e.DataRow("收件联系人手机") = pr("手机号码")
e.DataRow("客户型") = False
End If
End If
请看看有不有问题?