【问题标题】:Loading file on axacropdf (pdf component) from mixed listbox从混合列表框中加载 axacropdf(pdf 组件)上的文件
【发布时间】:2018-02-03 23:45:57
【问题描述】:

我正在获取文件夹名称,并在同一目录中获取 pdf 文件,并使用以下代码在同一个列表框中列出两者:

        Private Sub frmBooks_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each folder As String In System.IO.Directory.GetDirectories(Application.StartupPath & "\Books")
        ListBox1.Items.Add(Path.GetFileName(folder))
    Next
    For Each file As String In System.IO.Directory.GetFiles(Application.StartupPath & "\Books\", "*.pdf")
        ListBox1.Items.Add(Path.GetFileNameWithoutExtension(file))
    Next

两者在同一个列表框中混合和排序1 然后我添加 axacropdf(PDF 组件)来阅读 pdf 文件。 如何从列表框中的选定项目打开/获取路径以在 axacropdf 中打开?

(axacropdf.src =)

【问题讨论】:

    标签: vb.net pdf selecteditem listboxitem axacropdf


    【解决方案1】:

    此代码检查文件是否以 .pdf 格式存在

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        If File.Exists(Application.StartupPath & "\Books\" & ListBox1.SelectedItem.ToString & ".pdf") = True Then
            AxAcroPDF1.src = (Application.StartupPath & "\Books\" & ListBox1.SelectedItem.ToString & ".pdf")
    end if
       end sub
    

    【讨论】:

      猜你喜欢
      • 2013-09-08
      • 2020-08-02
      • 1970-01-01
      • 2017-03-09
      • 2012-06-12
      • 2010-12-24
      • 2018-10-28
      • 1970-01-01
      • 2014-10-13
      相关资源
      最近更新 更多