0

I am trying to add a List(Of T) to a Listview in Windows form application.But not able to do it.
I have made a form and took the value of textboxes in a list and trying to bind the list to ListView

3
Contributors
2
Replies
12
Views
3 Years
Discussion Span
Last Post by tinstaafl
0

You can try writing a custom fill function:

Private Function Fill(ByVal lstIN As List(Of T)) As Boolean
    Try
        Dim lvi As New ListViewItem

        lvi.Text = lstIN(0) 'if index 0 is a unique - Column 1
        lvi.SubItems.Add(lstIN(1)) 'Column 2 in listview
        lvi.SubItems.Add(lstIN(2)) 'Column 3

        ListView1.Items.Add(lvi)

        Return True
    Catch ex As Exception
        Return False
    End Try
End Function

Edited by Begginnerdev

0

If your list is a simple or integrated type and you only need 1 column, you can use it as a datasource for a Listbox, which is basically the same output.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.