Question[Help]List View[Solved]

Posts 1–4 of 4 · Page 1 of 1
[Help]List View[Solved]
I have:

Code:
OpenFileDialog1.ShowDialog()
        Dim FileName As String
        FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
        Dim FileName2 As String = FileName.Replace("\", "")
        ColumnHeader1.ListView.Items.Add(FileName2)
        ColumnHeader2.ListView.Items.Add(OpenFileDialog1.FileName)
I have two columns in a list view and I'm trying to get it to where you browse for a file it inserts the name in the first column then the file path in the second...I can't get it to insert the path into the second, its inserting it into the first one 2nd line. Help?

Then I want to take those file names and insert them into a text box, like button 3 hit and it inserts column 1 line 3 into the text box.


+Rep +1 Thanks.
I'm noobish but try this

Code:
   Private Sub OpenFileDialog1_FileOk_1(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        For Each track As String In OpenFileDialog1.FileNames
            ListBox1.Items.Add(track)
        Next
        For Each track2 As String In OpenFileDialog1.SafeFileNames
            ListBox2.Items.Add(track2)
        Next
    End Sub
Give this a shot:

Code:
Using ofd As New OpenFileDialog
    If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
        Dim filename As String = IO.Path.GetFileName(ofd.FileName)
        ListView1.Items.Add(filename)
        ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(ofd.FileName)
    End If
End Using


The second column is a "subitem" with the first column being an Item.
Update
Okay That works


Thanks.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?