--
ComboBox作为一个数据输入控件,可以人工输入但不能和现有的数据重复,当第一次输入不重复数值后离开控件后自动保存数据,以便以后输入数据时可以选择.
代码如下:
Dim s As String = GetConfigValue("List","")
Dim cmb As WinForm.ComboBox
cmb = e.Form.Controls("csComboBox")
Dim lst As new List(of String)
For i As Integer = 0 To cmb.Items.Count - 1
If lst.contains(cmb.Items(i)) Then
msgbox(cmb.Items(i) & "有重复")
Return
Exit For
Else
SaveConfigValue("List",s & "|" & e.Sender.text)
End If
Next
在enter事件中写入如下代码:
e.Sender.ComboList = GetConfigValue("List","")