VB.NET MS Access - Images and Text

| Page Views: 1404

ListView in VB.NET and .NET general is powerful component that can render lists or tables of data.

It's customizable and powerful and can be used with a variety of data source through data binding.

However, we can also add data programmatcially by creating ListViewItems and adding them.

This means that we can create our rows using custom logic. Moreover ListView is flexible and allows us even render binary data like images in our rows.

In this class we render both images and text in our ListView.

Here we explore vb.net ListView.How to load and show images and text from our file system into our listview.


Imports System.IO

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ListView1.FullRowSelect = True

        ListView1.Columns.Add("Name", 250)

    End Sub

    Private Sub populate()
        Dim imgs As ImageList = New ImageList()
        imgs.ImageSize = New Size(50, 50)

        'our files img
        Dim files As String() = New String() {}
        files = Directory.GetFiles("D:/Imgs")

            For Each f In files

        Catch ex As Exception

        End Try

        ListView1.SmallImageList = imgs
        ListView1.Items.Add("Michael carrick", 0)
        ListView1.Items.Add("Diego Costa", 1)
        ListView1.Items.Add("David De Gea", 2)
        ListView1.Items.Add("Eden Hazard", 3)
        ListView1.Items.Add("Anders Herera", 4)
        ListView1.Items.Add("Oscar", 5)
        ListView1.Items.Add("Aaron Ramsey", 6)

    End Sub

    Private Sub populateBtn_Click(sender As Object, e As EventArgs) Handles populateBtn.Click

    End Sub

    Private Sub clearBtn_Click(sender As Object, e As EventArgs) Handles clearBtn.Click
    End Sub

    Private Sub ListView1_MouseClick(sender As Object, e As MouseEventArgs) Handles ListView1.MouseClick

    End Sub
End Class

Best Regards.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:


What do You Think

Previous Post Next Post