Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF VB.NET:如何在列表框中插入记事本_Wpf_Vb.net_Listbox - Fatal编程技术网

WPF VB.NET:如何在列表框中插入记事本

WPF VB.NET:如何在列表框中插入记事本,wpf,vb.net,listbox,Wpf,Vb.net,Listbox,我已经使用了下面的代码 Dim openfile1 = New Microsoft.Win32.OpenFileDialog With {.Filter = "Text (*.Text)|*.txt"} If (openfile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then For Each line As String In File.ReadAllLines(openfile1.

我已经使用了下面的代码

 Dim openfile1 = New Microsoft.Win32.OpenFileDialog With {.Filter = "Text (*.Text)|*.txt"}
        If (openfile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
            For Each line As String In File.ReadAllLines(openfile1.FileName)
                ListBox1.Items.Add(line)
            Next
        End If
此代码用于windows窗体,当我在WPF中使用时,没有错误,但无法在列表框上显示记事本的内容。没有其他解决方案

File.IO.ReadAllLines将返回字符串数组而不是集合。最好使用For循环


Foreach statement=您需要一个集合对象

抱歉。。我必须向我的同事寻求解决办法。System.Windows.Forms.DialogResult上存在错误
  Dim openfile1 = New Microsoft.Win32.OpenFileDialog With {.Filter = "Text (*.Text)|*.txt"}
            If (openfile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
                For i = 0 To Ubound(File.ReadAllLines(openfile1.FileName),1)
                    ListBox1.Items.Add(File.ReadAllLines(openfile1.FileName)(i))
                Next
            End If