Click here to Skip to main content
15,910,785 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Big Bug in ComboBox control Pin
J4amieC25-May-05 22:09
J4amieC25-May-05 22:09 
GeneralRe: Big Bug in ComboBox control Pin
rushing25-May-05 22:39
rushing25-May-05 22:39 
GeneralRe: Big Bug in ComboBox control Pin
rushing25-May-05 22:41
rushing25-May-05 22:41 
GeneralRe: Big Bug in ComboBox control Pin
Christian Graus26-May-05 11:35
protectorChristian Graus26-May-05 11:35 
GeneralReading a txt file in textbox from listview Pin
WetRivrRat25-May-05 17:26
WetRivrRat25-May-05 17:26 
GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus25-May-05 17:38
protectorChristian Graus25-May-05 17:38 
GeneralRe: Reading a txt file in textbox from listview Pin
WetRivrRat26-May-05 2:53
WetRivrRat26-May-05 2:53 
GeneralRe: Reading a txt file in textbox from listview Pin
Dave Kreskowiak26-May-05 3:45
mveDave Kreskowiak26-May-05 3:45 
You've got a couple of problems. The ListViewItems don't have the full path to the files because you never saved the full path in them. You need both the filename so you can show the user just that, the short filename, and you need the full path to the file so your code can get it easily. You're only doing one of those things.

The ListViewItem class has a Tag property that can store just about any type of object. In your code, it's probably a good idea to store the full path to the file in there so you can retrieve it later when you go to open the file.
Dim dirInfo As New DirectoryInfo(e.Node.FullPath)
If (dirInfo.Exists) Then
    ListView1.Items.Clear()
    Dim fileInfos As FileInfo() = dirInfo.GetFiles()
    Dim info As FileInfo
    For Each info In fileInfos
        Dim item As New ListViewItem(info.Name)
        item.SubItems.Add(info.LastAccessTime.ToString())
        item.Tag = info.FullName
        ListView1.Items.Add(item)
    Next
End If

Now, your second problem. When you go and open the file in your doubleclick handler, you're actually creating a new instance of a ListViewItem, a blank one!, and using that to supply the filename your trying to launch. Obviously, you can't do that. You have to use the selected item in the ListView.
Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
    Try
        System.Diagnostics.Process.Start(ListView1.SelectedItem.Tag)
    Catch ex As Exception
        MsgBox(Err.Description, vbCritical, "Error " & CStr(Err.Number))
    End Try
End Sub

* Note: The code in this post has NOT been tested.


RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus26-May-05 11:39
protectorChristian Graus26-May-05 11:39 
GeneralRe: Reading a txt file in textbox from listview Pin
WetRivrRat26-May-05 13:05
WetRivrRat26-May-05 13:05 
GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus26-May-05 14:14
protectorChristian Graus26-May-05 14:14 
GeneralRe: Reading a txt file in textbox from listview Pin
WetRivrRat26-May-05 15:02
WetRivrRat26-May-05 15:02 
GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus26-May-05 15:07
protectorChristian Graus26-May-05 15:07 
GeneralRe: Reading a txt file in textbox from listview Pin
WetRivrRat26-May-05 15:31
WetRivrRat26-May-05 15:31 
GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus26-May-05 15:33
protectorChristian Graus26-May-05 15:33 
GeneralRe: Reading a txt file in textbox from listview Pin
Dave Kreskowiak27-May-05 2:14
mveDave Kreskowiak27-May-05 2:14 
GeneralRe: Reading a txt file in textbox from listview Pin
Dave Kreskowiak27-May-05 2:15
mveDave Kreskowiak27-May-05 2:15 
GeneralRe: Reading a txt file in textbox from listview Pin
Christian Graus27-May-05 2:45
protectorChristian Graus27-May-05 2:45 
GeneralConnect to MS Outlook Pin
dw192825-May-05 16:01
dw192825-May-05 16:01 
GeneralRe: Connect to MS Outlook Pin
pfalco26-May-05 10:48
pfalco26-May-05 10:48 
GeneralImages in a Usercontrol Pin
tibmark25-May-05 15:57
tibmark25-May-05 15:57 
GeneralRe: Images in a Usercontrol Pin
Christian Graus25-May-05 16:05
protectorChristian Graus25-May-05 16:05 
GeneralRe: Images in a Usercontrol Pin
tibmark25-May-05 16:18
tibmark25-May-05 16:18 
GeneralRe: Images in a Usercontrol Pin
Christian Graus25-May-05 16:22
protectorChristian Graus25-May-05 16:22 
GeneralRe: Images in a Usercontrol Pin
tibmark25-May-05 16:47
tibmark25-May-05 16:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.