代码改后仍然有问题:
If e.Selected Then '如果选择了值
Dim tbl As Table = Tables("客户信息_Table1")
If tbl.Current IsNot Nothing Then
e.Form.DropDownBox.Value = tbl.Current("客户电话")
Forms("订单新增").Controls("DropBox3").Text = tbl.Current("客户名称")
'e.Form.DropDownBox.Value = tbl.Current("客户电话")
If e.Form.DropTable IsNot Nothing Then '如果是通过表下拉的
e.Form.DropTable.FinishEditing()
Else '如果是通过窗口下拉的
e.Form.DropDownBox.WriteValue()
Forms("订单新增").Controls("DropBox3").WriteValue()
End If
End If
End If
改成以上代码后,出现客户电话和客户名称不对应的问题,当选择客户电话后,客户名称出来的是上一次记录的客户名称:
此主题相关图片如下:tim截图20180809150838.jpg

现在是客户名称绑定到销售订单.客户名称,客户电话绑定到销售订单.客户电话,而下拉窗口都绑定了“客户信息”下拉窗口,TextChanged、Validating,KeyPress,KeyDown代码都相同:
TextChanged:
Dim drp As WinForm.DropDownBox = e.sender
If drp.DroppedDown Then '如果下拉窗口已经打开
Dim tbl As Table = Tables("客户信息_Table1")
If drp.Text = "" Then '如果内容为空
tbl.Filter = "" '显示所有客户
Else '否则根据输入内容进行模糊筛选
Dim txt As String = "'%" & drp.Text & "%'"
tbl.Filter = "客户电话 Like " & txt & " Or 客户名称 Like " & txt
End If
End If
Validating:
Dim drp As WinForm.DropDownBox = e.sender
If drp.DroppedDown Then '如果下拉窗口已经打开
drp.CloseDropdown(False) '关闭下拉窗口
End If
KeyPress:
Dim drp As WinForm.DropDownBox = e.Sender
If drp.DroppedDown = False '如果下拉窗口没有打开
drp.OpenDropDown() '打开下拉窗口
End If
KeyDown:
Dim drp As WinForm.DropDownBox = e.sender
If drp.DroppedDown Then '如果下拉窗口已经打开
Dim tbl As Table = Tables("客户信息_Table1")
If e.KeyCode = Keys.Up Then '如果按下的是上箭头按键
tbl.Position = tbl.Position - 1 '向上移动一行
e.Cancel = True
ElseIf e.KeyCode = Keys.Down Then '如果按下的是下箭头按键
tbl.Position = tbl.Position + 1 '向下移动一行
e.Cancel = True
End If
End If
[此贴子已经被作者于2018/8/9 21:30:52编辑过]