how to add images to a Listviewgroup

Asked

Viewed 49 times

0

Let’s suppose that way: C:\...\imagem have 3 folders: fotos, wallpaper and ferias. What I’d like to do and leave them like this:

Photos

imagem1           imagem2              imagem3

imagem4           imagem5              imagem6

Wallpaper

imagem1           imagem2              imagem3

imagem4           imagem5              imagem6

Holidays

imagem1           imagem2              imagem3

imagem4           imagem5              imagem6

I already picked up the paths and the images, but I’m picking up for this listview someone knows how I do it?

If possible using Vb I don’t know C language#

Edit:

I’m using a Treeview to list all the folders in a directory that have images . jpg

 Dim td As Threading.Thread


Private Sub Anteslerdiretorio()
    Dim nome As String = "Imagem"
    Dim caminho As String = "C:\Users\lucas\Imagem\fotos"

    Dim cont As Integer = 0


    'Dim node As TreeNode = New TreeNode(nome)
    Me.Invoke(New Action(Function() Me.TreeView1.Nodes.Add(nome)))

    LerDiretoriosEArquivosRecursivamenteEAdicionarAaTreeView(caminho, TreeView1.Nodes(cont))
    cont += 1



End Sub

Private Sub LerDiretoriosEArquivosRecursivamenteEAdicionarAaTreeView(ByVal diretorio As String, ByVal noPai As TreeNode)

    Dim dirsFilhos() As String = System.IO.Directory.GetDirectories(diretorio)
    If dirsFilhos.Length = 0 Then
        Return
    Else
        For Each dirFilho In dirsFilhos
            Try
                For Each arquivos In FileIO.FileSystem.GetFiles(dirFilho, FileIO.SearchOption.SearchAllSubDirectories, "*.jpg", "*.png")
                    If Len(arquivos) > 0 Then
                        Dim noFilho As TreeNode = New TreeNode(dirFilho)
                        Me.Invoke(New Action(Function() noPai.Nodes.Add(noFilho)))
                        'noPai.Nodes.Add(noFilho)
                        LerDiretoriosEArquivosRecursivamenteEAdicionarAaTreeView(dirFilho, noFilho)
                        Exit For
                    End If
                Next
            Finally
            End Try
        Next
    End If
End Sub

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click


    td = New Threading.Thread(AddressOf Anteslerdiretorio)

    td.Start()

End Sub

And then using a treeview Afterselect event to pick up the selected path in Treeview and the images in the selected folder.

Private Sub PegaCaminhoTreeview(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect

    If TreeView1.SelectedNode Is Nothing Then
        Exit Sub
    End If


    Dim thumbnail As New ImageList With {.ImageSize = New Size(256, 200), .ColorDepth = ColorDepth.Depth32Bit}
    Dim caminho_saida As String = TreeView1.SelectedNode.Text
    Dim xx As Image

    Try
        For Each caminho_imagens In FileIO.FileSystem.GetFiles(TreeView1.SelectedNode.Text, FileIO.SearchOption.SearchTopLevelOnly, "*jpg", "*.png")
            Using str As Stream = File.OpenRead(caminho_imagens)
                xx = Image.FromStream(str)
                thumbnail.Images.Add(xx)
            End Using
        Next
    Finally
    End Try
End Sub

What I’d like to know is how do I do an exhibition of this kind: inserir a descrição da imagem aqui

Only with the name of the last folder being the group name and its images within the group folder.

  • Hello @Lucas, have any code already done?

  • @Lucas what is the specific doubt? Code please.

  • I edited the question.

  • What exactly is your difficulty?

  • Create the group in Listview with the folder name and place its images inside the same group in the image above.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.