以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  组合框下拉多列的请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81130)

--  作者:douglas738888
--  发布时间:2016/2/19 9:40:00
--  组合框下拉多列的请教
老师,我在论坛中看了类似的提问有几个,我引用了其中的代码,但对代码理解不是很明白,问题如下:

在窗口的工号组合框下拉时,已显示了 001/老李,但点击选择后,填入组合框的是 001/老李,而不是001,

SelectedIndexChanged引用代码

Dim arys As List(Of String()) = DataTables("员工档案").GetValues("员工工号|员工姓名","员工工号 is not null")
Dim str As String = ""
Dim s1, s2 As Integer
For Each s As String() In arys
    If s(0).Length > s1 Then
        s1 = s(0).Length
    End If
    If s(1).Length > s2 Then
        s2 = s(1).Length
    End If
Next
For Each s As String() In arys
    str &= s(0).PadLeft(s1) & "/" & s(1).PadLeft(s2) & "|"
Next
e.Form.Controls("ComboBox1").ComboList = str.Trim("|")

--  作者:大红袍
--  发布时间:2016/2/19 9:50:00
--  

上面的代码,你应该写到AfterLoad事件

 

SelectedIndexChanged事件的代码这样写

 

e.Sender.Text = e.Sender.Text.Split("/")(0)