以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  有关CheckedComboBox控件  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=2689)

--  作者:baoxyang
--  发布时间:2009/5/5 16:56:00
--  有关CheckedComboBox控件
在CheckedComboBox控件,显示列为“货损代号”。在SelectedIndexChanged事件中得到对应货损代号的货损描述列值。


Dim lst As WinForm.CheckedComboBox
lst = e.Form.Controls("CheckedComboBox1")
Dim dr As DataRow = lst.SelectedItem
if dr IsNot nothing then
   e.Form.Controls("TextBox20").value = dr("货损描述")
end if

但提示错误。不知那里出错了,请各位指点! 


图片点击可在新窗口打开查看此主题相关图片如下:未命名1.gif
图片点击可在新窗口打开查看

--  作者:baoxyang
--  发布时间:2009/5/5 16:58:00
--  
CheckedComboBox控件是绑定数据库的。此数据库有两列,一列为货损代码,一列为货损描述
--  作者:狐狸爸爸
--  发布时间:2009/5/5 17:05:00
--  
请做个简单的例子看看
--  作者:baoxyang
--  发布时间:2009/5/5 17:58:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目2.rar


--  作者:baoxyang
--  发布时间:2009/5/5 18:07:00
--  
哦,忘记在SelectedIndexChanged事件加入如下代码:
Dim lst As WinForm.CheckedComboBox
lst = e.Form.Controls("CheckedComboBox1")
Dim dr As DataRow = lst.SelectedItem
if dr IsNot nothing then
   e.Form.Controls("TextBox20").value = dr("货损描述")
end if

不好意思!
--  作者:mr725
--  发布时间:2009/5/5 19:18:00
--  
不需要在SelectedIndexChanged事件加代码;
把下面代码放到CheckedComboBox1 的 textchenged事件中:(只适合选择单项内容

Dim lst As WinForm.CheckedComboBox
lst = e.Form.Controls("CheckedComboBox1")
if lst.text = nothing then
    e.Form.Controls("TextBox1").value = ""
else
    dim dr as DataRow  = DataTables("货损信息").find("货损代码 = \'" & lst.value & "\'")
    if dr isnot nothing then
        e.Form.Controls("TextBox1").value = dr("货损描述")
    end if
end if
[此贴子已经被作者于2009-5-5 20:13:23编辑过]

--  作者:baoxyang
--  发布时间:2009/5/5 19:44:00
--  
楼主,测过不,单项选择可以,但多项就出错呀.如单项的话,还不如用ComboBox.楼主试过多项可以吗?
--  作者:mr725
--  发布时间:2009/5/5 20:16:00
--  
哈哈~ 搂主是你自己啊~!!!
多项选择,要请教其他老师或狐爸了。。。。  sorry!

顺便问一下: 一共有多少选项啊? 或是不确定?
[此贴子已经被作者于2009-5-5 20:26:34编辑过]

--  作者:mr725
--  发布时间:2009/5/5 21:34:00
--  
如果只有两个选项的话,把下面代码放到CheckedComboBox1 的 textchenged事件中:(不确定选项个数的话,请大师们帮忙啦~,我不行了~呵呵!)
Dim lst As WinForm.CheckedComboBox
lst = e.Form.Controls("CheckedComboBox1")
if lst.text = nothing then
    e.Form.Controls("TextBox1").value = ""
else
if lst.text like "*,*"
    Dim Multi As string = forms("窗口1").controls("checkedcombobox1").text
    Dim Values as String() 
    Values = Multi.split(",")   
    dim hs1 as string = values(0)
    dim hs2 as string = values(1)   
    dim dr1 as DataRow  = DataTables("货损信息").find("货损代码 = \'" & hs1 & "\'")
    dim dr2 as DataRow  = DataTables("货损信息").find("货损代码 = \'" & hs2 & "\'")
    if dr1 isnot nothing andalso dr2 isnot nothing then
    forms("窗口1").Controls("TextBox1").value = dr1("货损描述")  & "," & dr2("货损描述")
    end if 
else
    dim dr as DataRow  = DataTables("货损信息").find("货损代码 = \'" & lst.text & "\'")
    if dr isnot nothing then
        e.Form.Controls("TextBox1").value = dr("货损描述")
    end if
end if
end if

--  作者:baoxyang
--  发布时间:2009/5/5 21:37:00
--  

那肯定不止两个呀,是不确定的.可以达到,只不过繁杂了点.