本文介绍了添加项目到组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将文件夹Letters中的所有文件名添加到我的组合框中,如下代码:
ComboBox3.Items.Add(FileIO.FileSystem.GetName(My.Application.Info.DirectoryPath& \ Letters\test))
但是这段代码只是将test添加到我的组合框中,但我想添加文件夹Letters中的所有文件名。
我只想要文件名。
给我一些例子。
请帮助我。
谢谢。
I want to add all file names from folder"Letters" to my combobox like this code:
ComboBox3.Items.Add(FileIO.FileSystem.GetName(My.Application.Info.DirectoryPath & "\Letters\test"))
But this code just add "test" to my combobox but I want to add all file names from folder "Letters".
I want just file names.
Give me some examples.
Please help Me.
Thank You.
推荐答案
For Each f As String In FileIO.FileSystem.GetFiles(My.Application.Info.DirectoryPath & "\Letters\test"))
ComboBox1.Items.Add(f)
Next
这是获取文件名的第一部分的一种(笨重)方式
Here is one (clunky) way of getting just the first part of the filename
For Each f As String In FileIO.FileSystem.GetFiles("c:\\develop")
Dim s() As String
s = f.Split(New Char() {".", "\\"})
ComboBox1.Items.Add(s(s.GetUpperBound(0) - 1))
Next
这篇关于添加项目到组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!