问题描述
我必须说,我完全不知道应该是一个非常简单的
sub ...
它的目的是使用指定路径
的文件名填充ListBox。我知道Files()接收文件名,但是ListBox
什么也没做!没有项目出现,我已经尝试了一切。没有
异常出现,什么都没有。
这里是子...我错过了什么?我也试过单独添加
项目(例如ListBox1.Add(Files(0))等,但没有用)。
Public Sub FillListBox()
Dim Path As String
Dim Files()As System.Object
Path = DriveLetter& " \ DOCS \"
Files = Directory.GetFiles(Path)
ListBox1.BeginUpdate()
ListBox1.Items.AddRange(Files)
ListBox1.EndUpdate()
结束子
非常感谢,
MrQuan
I must say, I''m completly stumped at what should be a very simple
sub...
It''s purpose is to fill a ListBox with filenames from the path
specified. I know Files() receives the filenames, however the ListBox
doesn''t do anything!! No items appear, I''ve tried everything. No
exceptions arise, nothing.
Here''s the sub... am I missing something? I''ve also tried adding the
items individually (e.g. ListBox1.Add(Files(0)) etc, with no avail).
Public Sub FillListBox()
Dim Path As String
Dim Files() As System.Object
Path = DriveLetter & "\DOCS\"
Files = Directory.GetFiles(Path)
ListBox1.BeginUpdate()
ListBox1.Items.AddRange(Files)
ListBox1.EndUpdate()
End Sub
Many thanks,
MrQuan
推荐答案
< snip>
<snip>
< snip>
这里工作正常。
也许你设置了ListBox的数据源并忘了清除它? br />
问候,
布兰科。
<snip>
It works ok here.
Maybe you set the ListBox''s DataSource and forgot to clear it?
Regards,
Branco.
这篇关于ListBox无法正常工作?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!