在窗口中的组合框中,也要自定义的下拉列表。对ComboList进行定义:
在窗体afterload事件中的代码如下,对“分类”进行定义下拉列表:
Dim Items As String
Dim lst As List(Of String) = DataTables("A表").GetuniqueValues("","分类")
For Each Item As String In Lst
Items = Items & "|" & Item
Next
e.Form.Controls("ComboBox1").ComboList = Items
在“名称”的Enter事件中设置代码(选择控件执行):
If e.Form.Controls("ComboBox1").value is nothing Then '如果分类列的内容为空
e.Form.Controls("ComboBox2").Combolist = "" '清除名称列的列表项目
Else
Dim drs As New List(Of string) '字符串集合
drs = DataTables("A表").GetUniqueValues("[分类]='" & e.Form.Controls("ComboBox1").value & "'" , "名称")
'方法一:
' Dim Val AS String = "|"
' For Each dr As string In drs
' Val = Val & "|" & dr
' Next
' e.Form.Controls("ComboBox2").Combolist = Val
'方法二:
e.Form.Controls("ComboBox2").Items.Clear
e.Form.Controls("ComboBox2").Items.AddRange(drs.ToArray()) '将一个字符数组的内容全部加入到列表项目中.
End If
此主题相关图片如下:分类与名称的窗体筛选.jpg