以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]组合框  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=82268)

--  作者:江南小城
--  发布时间:2016/3/15 8:37:00
--  [求助]组合框

老师好,组合框1、组合框2、组合框3多调用列表项目表中的同一个列中的字段,现在是单个写的。我要把代码合起来写。

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:新建 文本文档.txt


--  作者:Hyphen
--  发布时间:2016/3/15 9:17:00
--  
写个内部函数,比如SetComboList

Dim cate = Args(0)
Dim xll As New SQLCommand
Dim xl As DataTable
xll.C
xll.CommandText = "SEL ECT DIST INCT " & cate & " From {列表项目}"
xl = xll.ExecuteReader
If Args.length > 1 Then
    For i As Integer = 1 To Args.length - 1
        Dim cbo = Args(i)
        cbo.ComboList = xl.GetComboListString(cate)
    Next
End If

调用
Functions.Execute("SetComboList","学历",e.Form.Controls("ComboBox1"),e.Form.Controls("ComboBox1"),e.Form.Controls("ComboBox3"))

--  作者:江南小城
--  发布时间:2016/3/15 10:50:00
--  

老师,怎样调用。


--  作者:大红袍
--  发布时间:2016/3/15 10:51:00
--  
调用
 
Functions.Execute("SetComboList","学历",e.Form.Controls("ComboBox1"),e.Form.Controls("ComboBox1"),e.Form.Controls("ComboBox3"))

--  作者:大红袍
--  发布时间:2016/3/15 10:56:00
--  

直接在afterLoad事件写也可以

 

Dim cate() As String = {"combobox1", "combobox2", "combobox3"}
Dim xll As New SQLCommand
Dim xl As DataTable
xll.ConnectionName = "管理"
xll.CommandText = "SELECT DISTINCT 学历 Fr om {列表项目}"
xl = xll.ExecuteReader
Dim str As String = xl.GetComboListString("学历")
For i As Integer = 0 To cate.length - 1
    Dim cbo = e.form.controls(cate(i))
    cbo.ComboList = str
Next

 


--  作者:江南小城
--  发布时间:2016/3/15 10:57:00
--  
以下是引用Hyphen在2016/3/15 9:17:00的发言:
写个内部函数,比如SetComboList

Dim cate = Args(0)
Dim xll As New SQLCommand
Dim xl As DataTable
xll.C
xll.CommandText = "SEL ECT DIST INCT " & cate & " From {列表项目}"
xl = xll.ExecuteReader
If Args.length > 1 Then
    For i As Integer = 1 To Args.length - 1
        Dim cbo = Args(i)
        cbo.ComboList = xl.GetComboListString(cate)
    Next
End If

老师,代码报错
--  作者:大红袍
--  发布时间:2016/3/15 11:00:00
--  
 汗,你要看懂代码,不会做,就用5楼。