当前位置:编程学习 > C#/ASP.NET >>

vb.net 的openfiledialog问题

怎么把openfiledialog选中的多个文件的文件名导入到列表listbox中呀 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.Multiselect = True If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then If Not (OpenFileDialog1.FileName Is Nothing) Then add(OpenFileDialog1.FileName) End If End If End Sub Private Sub add(ByVal pp As String) MessageBox.Show(pp, "adsd") If pp <> "" Then ListBox1.BeginUpdate() ListBox1.Items.Add(pp) ListBox1.EndUpdate() End If End Sub 就是搞不出,只有一个导入了进去
答案:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Multiselect = True
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            ListBox1.Items.Clear()
            ListBox1.Items.AddRange(OpenFileDialog1.FileNames)
        End If
    End Sub

上一个:寻求 VB.net开发网络程序的意见
下一个:ASP.NET中VB.net的简单语句,请高人指导下

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,