换个角度看问题,以下是我的通用录入框对于不允许直接输入的控制:
If e.Form.Controls("TreeView录入树").AllNodes.Count < 1 Then
MessageBox.Show("没有选择数据")
e.Form.DropDownBox.Text = ""
ElseIf e.Form.Controls("TreeView录入树").AllNodes.Count > = 1 Then
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView录入树")
Dim i As Integer = 0
For Each nd As WinForm.TreeNode In trv.AllNodes
If nd.Level = 0 AndAlso e.Form.DropDownBox.Text = nd.Name Then
i = i + 1
End If
Next
If i = 0 Then
MessageBox.Show("没有选择数据")
e.Form.DropDownBox.Text = ""
End If
End If