|
-
Jan 20th, 2003, 12:30 AM
#1
Thread Starter
Lively Member
Current Selected Item (file) in Listview To String...
I have a ListView that fills itself with files from a selected Dir in a tree view. Now I need to get the path/filename of the selected item in the listviewinto a variable so I can pass it to another method.
I cant seem to figure it out.
Last edited by Jes|er; Jan 20th, 2003 at 12:37 AM.
12/32/84 - I need some code to make me a sandwhich.
-
Jan 20th, 2003, 12:37 AM
#2
Re: Current Selected Item (file) in Listview To String...
Originally posted by Jes|er
I have a ListView that fills itself with files from a selected Dir in a tree view. Now I need to get the path/filename of the selected item in the listview.
I cant seem to figure it out.
see if this little example helps. I just added a listview called lvw with a few items in it (assuming that you know the directory... )
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim currentDirectory As String = "C:"
If Not lvw.SelectedItems Is Nothing Then
Dim filePath As String
filePath = IO.Path.Combine(currentDirectory, lvw.SelectedItems(0).Text)
MsgBox(filePath)
End If
End Sub
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jan 20th, 2003, 02:35 PM
#3
Thread Starter
Lively Member
Thank you, been trying to figure this out.
12/32/84 - I need some code to make me a sandwhich.
-
Jan 20th, 2003, 02:37 PM
#4
Originally posted by Jes|er
Thank you, been trying to figure this out.
well, did you figure it out or not? did that work for you?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jan 20th, 2003, 08:07 PM
#5
Thread Starter
Lively Member
Well, I sort of figured it out. I got it to work.
But the problem now is that the Listview dosnt hold the Path, just the just the file name. So I figure I just have to grab the path from the treeview and conactinate it with the filename. Not sure how I'm going to do that yet. But I'm off to try now.
Last edited by Jes|er; Jan 20th, 2003 at 08:58 PM.
12/32/84 - I need some code to make me a sandwhich.
-
Jan 20th, 2003, 11:06 PM
#6
Originally posted by Jes|er
Well, I sort of figured it out. I got it to work.
But the problem now is that the Listview dosnt hold the Path, just the just the file name. So I figure I just have to grab the path from the treeview and conactinate it with the filename. Not sure how I'm going to do that yet. But I'm off to try now.
well yeah you could get the path from the treeview too....
my question is, dont you have the path of the folder at some point? because you are loading all the directories in that folder to the listview, so I guess you have to know the parent folder's path at some point. Why not just save that path in a public variable rather than trying to figure it out again from the treeview?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jan 21st, 2003, 12:36 AM
#7
Thread Starter
Lively Member
I wish it was that simple. The treeview lists all the drives on the computer. Its like explorer, only without all the fancy folder gifs 
So the path is not constant, it changes as the user switchs drives and folders. Sorry I should have made that clear before.
Im currently playing around with Directory.GetCurrentDirectory
and dont seem to be getting anywhere. Well I'll give it another go in the morning.
12/32/84 - I need some code to make me a sandwhich.
-
Jan 21st, 2003, 12:44 AM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|