Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共9 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]ComboBox的下拉列表值

1楼
johnbu 发表于:2012/2/9 9:29:00

求教

     我现在用动态的向一个窗口添加两个ComboBox,第一个取值表A的一列,然后第二个ComboBox根据第一个ComboBox的值来取表A的第二列值,我现在的做法是把它加到了窗口Afterload事件里,但现在我点第二个ComboBox时无法从第一个ComboBox取值并筛选表A的第二列值。或者能不能告诉我怎么来动态的设置ComboBox的Enter事件

2楼
狐狸爸爸 发表于:2012/2/9 9:55:00

这里有例子:

 

http://www.foxtable.com/help/topics/1523.htm

 

3楼
johnbu 发表于:2012/2/9 10:22:00

If e.Sender.Name.SubString(0,4) = "ComboBox2" Then '如果名称符合
    Dim cmbl As WinForm.ComboBox = e.Sender
    Dim str As String = e.Form.Controls("ComboBox1").Value
    cmbl.ComboList = DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'")
End If

 

我是这样写的,但是不生效,还请指教

4楼
狐狸爸爸 发表于:2012/2/9 10:26:00

在ComboxBox2的Enter事件中设置代码:

 

Dim cmb As WinForm.ComboBox = e.Sender

Dim str As String = e.Form.Controls("ComboBox1").Value
cmb.ComboList = DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'")

5楼
johnbu 发表于:2012/2/9 10:33:00
我的ComboBox2是一个动态添加的。在窗口中看不到,没法设置Enter事件
6楼
狐狸爸爸 发表于:2012/2/9 10:34:00

看看代码到底执行了没有:

 

MessageBox.show(e.Sender.Name)

If e.Sender.Name.SubString(0,4) = "ComboBox2" Then '如果名称符合

    MessageBox.show(e.Sender.Name)

    Dim cmbl As WinForm.ComboBox = e.Sender
    Dim str As String = e.Form.Controls("ComboBox1").Value
    cmbl.ComboList = DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'")
End If

7楼
johnbu 发表于:2012/2/9 10:55:00
执行了,但是还是没有取到值……
8楼
johnbu 发表于:2012/2/9 11:02:00

If e.Sender.Name.SubString(0) = "ComboBox2" Then '如果名称符合
    Dim cmbl As WinForm.ComboBox = e.Sender
    Dim str As String = e.Form.Controls("ComboBox1").Value
    cmbl.ComboList = DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'")
End If

 

找到原因了,是sustring的长度不够,把长度限制去掉就可以了,谢谢啦

9楼
狐狸爸爸 发表于:2012/2/9 11:21:00

不会有的别的原因,要么条件有问题,要么根本就没有符合条件的数据,这样检查一下:

 

If e.Sender.Name.SubString(0,4) = "ComboBox2" Then '如果名称符合

    Dim cmbl As WinForm.ComboBox = e.Sender
    Dim str As String = e.Form.Controls("ComboBox1").Value
    cmbl.ComboList = DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'")

    MessageBox.Show(Str)
    MessageBox.Show("物料 = '" & str & "'")

    MessageBox.Show(DataTables("现有量").GetComboListString("批号", "物料 = '" & str & "'"))

End If

共9 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.