Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.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
在vb.net中显示文档_Vb.net_File - Fatal编程技术网

在vb.net中显示文档

在vb.net中显示文档,vb.net,file,Vb.net,File,我有一个VB.NET表单,我想在其中显示文件的内容。 请告诉我哪一个是最好的工具箱组件,如果可能的话,举个小例子 我有一个解决方案,但我不喜欢它的工作方式: Private Sub DataGridView1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick T

我有一个VB.NET表单,我想在其中显示文件的内容。 请告诉我哪一个是最好的工具箱组件,如果可能的话,举个小例子

我有一个解决方案,但我不喜欢它的工作方式:

Private Sub DataGridView1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
    Try
        If e.RowIndex >= 0 AndAlso e.ColumnIndex >= 0 Then
            Dim selectedRow = DataGridView1.Rows(e.RowIndex)
            Dim i = DataGridView1.CurrentCellAddress.X
            Dim j = DataGridView1.CurrentCellAddress.Y
            Dim file_name As String = DataGridView1.Item(i, j).Value.ToString()
            TextBox2.Text = ""
            For Each s As String In File.ReadAllText("D:\Oracle\datastore\" & file_name)
                TextBox2.AppendText(s)
            Next

            'Dim sr As StreamReader = StreamReader("D:\Oracle\datastore\" & file_name)

        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
因为它一行一行地加载,如果是一本小说,则需要数周的时间才能完成


谢谢,

@AndrewMorton:我将每个s的
替换为File.ReadAllText(“D:\Oracle\datastore\”和File\u name)TextBox2.AppendText下一个
为新字符串生成器()sb.append(File.ReadAllText(“my\path\myfile”)TextBox2.text=sb.tostring()
但是,现在,我的文本看起来比以前小了。我说小是因为我无法检查它,因为它显示的是工件(有PDF和DOCXs文件),可以吗?哦,等等……你的意思是手动单击所有这些单元格需要很长时间吗?是的,我希望在单击单元格时,将相应的文件加载到文本框中。