Results 1 to 2 of 2

Thread: [Solved] Listview add subitems, more problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2009
    Posts
    16

    [Solved] Listview add subitems, more problems

    This is now solved, the correct code was
    Code:
    	Private Sub tvFolders1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvFolders1.AfterSelect
    		Dim id3folder As String
    		id3folder = e.Node.FullPath()
    		Dim objMP3Info As New _
    		Monotic.Multimedia.MP3.MP3Info()
    		files = FileIO.FileSystem.GetFiles(id3folder, FileIO.SearchOption.SearchAllSubDirectories, "*.mp3")		
    		For Each a As String In files
    			With lvFiles.Items.Add(FileIO.FileSystem.GetName(a))
    				objMP3Info.Filename = (FileIO.FileSystem.GetParentPath(a) + "\" + FileIO.FileSystem.GetName(a))
    				'MessageBox.Show(objMP3Info.Filename)
    				If (objMP3Info.ID3v1Tag.TagAvailable) Then
    					.SubItems.Add(objMP3Info.ID3v1Tag.Title)
    					.SubItems.Add(objMP3Info.ID3v1Tag.Artist) ' Title
    					.SubItems.Add(objMP3Info.ID3v1Tag.Album) ' Title
    					.SubItems.Add(objMP3Info.ID3v1Tag.Genre) ' Title
    					.SubItems.Add(objMP3Info.ID3v1Tag.Year) ' Title
    					.SubItems.Add(objMP3Info.ID3v1Tag.Title.Length) ' Title
    					' Source  -- Title -- Artist -- Album -- Genre -- Year -- Length
    				End If
    			End With
    		Next
    	End Sub
    I'm now trying a different approuch to my previous problem with the TreeView/ListView issue I had, this new "sollution" seems to be a bit more easy however I still can't solve it.

    The problem is to add the remaining listview.subitems, everything I try ether
    a: crashes app, or
    b: Only adds one subitem.
    If you take a look at the code you should see where my problem is, I where really hoping someone could help me solving it.
    Code:
        Private Sub tvFolders1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvFolders1.AfterSelect
            Dim id3folder As String
            id3folder = e.Node.FullPath()
            Dim objMP3Info As New _
            Monotic.Multimedia.MP3.MP3Info()
            files = FileIO.FileSystem.GetFiles(id3folder, FileIO.SearchOption.SearchAllSubDirectories, "*.mp3")
            '_U = Val(files)
            For Each a As String In files
                With lvFiles
                    objMP3Info.Filename = (FileIO.FileSystem.GetParentPath(a) + "\" + FileIO.FileSystem.GetName(a))                
                    'MessageBox.Show(objMP3Info.Filename)
                    If (objMP3Info.ID3v1Tag.TagAvailable) Then
                        lvFiles.Items.Add(FileIO.FileSystem.GetName(a)).SubItems.Add _
                        (objMP3Info.ID3v1Tag.m_strTitle)
    
                       ' I need to know the next stem for adding next subitem here, 
                       ' I've tried with everything I've come up with so far (Integers etc) but
                       ' to no avail
                        lvFiles.Items(.Columns.(e)).SubItems.Add(objMP3Info.ID3v1Tag.m_strTitle)
                    End If
                    
                    'MessageBox.Show(objMP3Info.ID3v1Tag.Title)
                End With
            Next
    
        End Sub
    Last edited by Tertitten; Mar 8th, 2009 at 06:24 AM. Reason: [Solved]

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Mar 2009
    Posts
    16

    Re: Listview add subitems, more problems

    Ok, so I've come a step further of solving this, no crashes now, however it adds all in the wrong places, so I'm still doing something wrong...

    Edit: Actually it adds the number 1 on every second item with no subitem loaded, so apparently i'm doing something very wrong with adding Items, not Subitems, these are now added correctly

    Here is the code I've got now, hopefully some of you can spot what I'm doing wrong
    Code:
        Private Sub tvFolders1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvFolders1.AfterSelect
            Dim id3folder As String
            Dim _U As Integer
            id3folder = e.Node.FullPath()
            Dim objMP3Info As New _
            Monotic.Multimedia.MP3.MP3Info()
            files = FileIO.FileSystem.GetFiles(id3folder, FileIO.SearchOption.SearchAllSubDirectories, "*.mp3")        
            For Each a As String In files
                _U = +1
                lvFiles.Items.Add(FileIO.FileSystem.GetName(a))
                With lvFiles.Items.Add(_U)
                    objMP3Info.Filename = (FileIO.FileSystem.GetParentPath(a) + "\" + FileIO.FileSystem.GetName(a))
                    'MessageBox.Show(objMP3Info.Filename)
                    If (objMP3Info.ID3v1Tag.TagAvailable) Then
                        .SubItems.Add(objMP3Info.ID3v1Tag.Title)
                        .SubItems.Add(objMP3Info.ID3v1Tag.Artist) ' Title
                        .SubItems.Add(objMP3Info.ID3v1Tag.Album) ' Title
                        .SubItems.Add(objMP3Info.ID3v1Tag.Genre) ' Title
                        .SubItems.Add(objMP3Info.ID3v1Tag.Year) ' Title
                        .SubItems.Add(objMP3Info.ID3v1Tag.Title.Length) ' Title
                        .SubItems.Add(objMP3Info.ID3v1Tag.Artist) ' Title
                        ' Source  -- Title -- Artist -- Album -- Genre -- Year -- Length
                    End If
                    'MessageBox.Show(objMP3Info.ID3v1Tag.Title)
                End With
            Next
        End Sub
    Last edited by Tertitten; Mar 8th, 2009 at 06:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width