Hi All,
I'm writing a program that uses a form with files on my hdd.
It's sort of a CMS. Now I was wondering if it is possible in vb.net to
simulate a double click like you can do in the windows explorer to
open a file. I'm using doc, xls, pdf, txt, rtf, ppt, html.
Otherwise I have to create a code for all different extensions to open
a file.
Marco
Hi All,
I found following simple line to open a document from the hdd:
System.Diagnostics.Process.Start(sDocumentName)
Now I have a Listview with filenames. When I click a file the name
gets stored to sDocumentName.
Protected Sub DocumentDetailHandler(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim I As Integer
Dim ID As Integer
For I = 0 To ListView.SelectedItems.Count - 1
ID = ListView.SelectedItems(I).Tag
Next
sDocumentName = ""
Dim sql As String = "SELECT * FROM Bestanden WHERE Id=" & ID
Dim cmd As New OleDbCommand(sql, conn)
Dim dr As OleDbDataReader
conn.Open()
dr = cmd.ExecuteReader()
Do While (dr.Read())
sDocumentName = dr.Item("hddlokatie") & dr.Item
("filenaam")
WebBrowser1.Url = New Uri("C:\" &
System.IO.Path.GetFileNameWithoutExtension(dr.Item("filenaam")) &
".html")
Loop
dr.Close()
conn.Close()
End Sub
But this happens only when I left-click the document.
When I right click a menu appears with the Open option:
Private Sub CMenuClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.ToolStripItemClickedEventArgs)
'Point to menu item clicked
Select Case e.ClickedItem.Text
Case "Open" : System.Diagnostics.Process.Start
(sDocumentName)
Case "Edit" : MsgBox("Edit")
Case "Delete" : MsgBox("Delete")
End Select
End Sub
So when I directly right-click and choose open the documentname is
empty.
Is there a better way to make sure I always have the right name to
open a document?
Regards
M<rco