以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  下拉框问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96617)

--  作者:yqd1968
--  发布时间:2017/2/24 12:27:00
--  下拉框问题
有表A和表B二个表均有产品列,我想在表C中产品列提取表A和表B产品列中不重复的值??如何处理??
--  作者:有点色
--  发布时间:2017/2/24 12:39:00
--  
Dim dt1 As DataTable = DataTables("表A")
Dim dt2 As DataTable = DataTables("表B")
Dim ls As new List(Of String)
For Each dr As DataRow In dt1.datarows
    If ls.Contains(dr("第一列")) = False Then
        ls.add(dr("第一列"))
    End If
Next
For Each dr As DataRow In dt2.datarows
    If ls.Contains(dr("第一列")) = False Then
        ls.add(dr("第一列"))
    End If
Next
Dim str As String = String.Join("|", ls.ToArray)
msgbox(str)
Tables("表C").cols("第一列").ComboList = str

--  作者:yqd1968
--  发布时间:2017/2/24 15:05:00
--  
谢谢有点色老师


--  作者:yqd1968
--  发布时间:2017/2/24 15:24:00
--  
有点色老师:
现在又有一个新问题出现了,
有表A和表B二个表均有产品列、规格列二列,我想在表C中根据已输入的产品列的值,在规格列中提取不重复的规格名称??
谢谢!


--  作者:有点色
--  发布时间:2017/2/24 15:32:00
--  

prepareEdit事件

 

If e.Col.name = "第二列" Then
    Dim dt1 As DataTable = DataTables("表A")
    Dim dt2 As DataTable = DataTables("表B")
    Dim ls As new List(Of String)
    For Each dr As DataRow In dt1.Select("第一列 = \'" & e.Row("第一列") & "\'")
        If ls.Contains(dr("第二列")) = False Then
            ls.add(dr("第二列"))
        End If
    Next
    For Each dr As DataRow In dt2.Select("第一列 = \'" & e.Row("第一列") & "\'")
        If ls.Contains(dr("第二列")) = False Then
            ls.add(dr("第二列"))
        End If
    Next
    Dim str As String = String.Join("|", ls.ToArray)
    e.Col.ComboList = str
End If


--  作者:yqd1968
--  发布时间:2017/2/24 16:11:00
--  
有点色老师十分感谢,我想在界面上查询这个规格时如何处理??

Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox3") \'定义一个变量
Dim txt As String = cb.Text \'定义一个变量的值
If Len(txt) = 0 Then \'len是返回字符串的长度,如果字符串长度是0
    cb.Items.Clear \'items是字符集合,表示所有的自定义列表项目,Clear是清除所有页面.
Else
    cb.ComboList = DataTables("监理合同台帐").GetComboListString("规格", "规格 Like \'%" & txt & "%\'") \'GetComboListString是从指定的列中提取不重复的值,用符号"|"将这些值连接成一个字符串,并返回这个字符串.
    If cb.DroppedDown = False Then
        cb.OpenDropDown()
    End If
End If

--  作者:有点色
--  发布时间:2017/2/24 16:22:00
--  
 没看懂你6楼表达的意思。现在有什么问题?
--  作者:yqd1968
--  发布时间:2017/2/24 16:31:00
--  
有点色老师:
上面这些均是在表与表之间的做法,我现在想在窗口中加入一个产品ComboBox和规格ComboBox,在产品中选择一个产品后,在规格中进行模糊选择??如何处理??
谢谢

--  作者:有点色
--  发布时间:2017/2/24 16:35:00
--  

 两个表?

 

Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim txt As String = cb.Text \'定义一个变量的值

Dim dt1 As DataTable = DataTables("表A")
Dim dt2 As DataTable = DataTables("表B")
Dim ls As new List(Of String)
For Each dr As DataRow In dt1.Select("第一列 like \'%" & txt & "%\'")
    If ls.Contains(dr("第二列")) = False Then
        ls.add(dr("第二列"))
    End If
Next
For Each dr As DataRow In dt2.Select("第一列 like \'%" & txt & "%\'")
    If ls.Contains(dr("第二列")) = False Then
        ls.add(dr("第二列"))
    End If
Next
Dim str As String = String.Join("|", ls.ToArray)

cb.ComboList = str