A little function problem

genu

Well-known member
Joined
Jun 9, 2005
Messages
94
Programming Experience
1-3
[RESOLVED]A little function problem

I made this function to populate a listview with data, but based on the columns its supposed decide wich part of te array to insert, but for some reason it doesnt do anything...it doesnt load anything into the listview:

VB.NET:
 Function populate_data()
        read = file.OpenText(System.AppDomain.CurrentDomain.BaseDirectory & "\data\soldiers.dat")
        While read.Peek <> -1
            On Error Resume Next
            Dim new_item As ListViewItem
            line_in = read.ReadLine
            in_array = Split(line_in, "|")
            Select Case main_list.Columns.Item(0).Text
                Case "First name"
                    new_item = main_list.Items.Add(in_array(0))
            End Select
            For i = 1 To main_list.Columns.Count
                Select Case main_list.Columns.Item(i).Text
                    Case "First Name"
                        new_item.SubItems.Add(in_array(0))
                    Case "Last Name"
                        new_item.SubItems.Add(in_array(1))
                End Select
            Next
        End While
    End Function
 
Last edited:
hey Kulrom btw, if you notice that I make the column width to 100, do you know how I can just make it fit the column text? because some columns are longer like for examples "Last name" would show up in the column header as "Last na..." I think u get the idea.

Thanks again for ur help
 
I read somewhere that If I make the column width -1, it would just autofit the text...but I guess thats not the case with the listview control...becase it didint work.
 
Back
Top