VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Add to a ListView control on the fly from a text datafile

by BP (8 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code will read in a two column data file (with the column titles in the first line) and update a listview control quickly and easily. It's easy to add more columns as needed. To use this code, you simply call the function like.
Call load_list_view_two(mylist, "c:\test.dat")

Rate Add to a ListView control on the fly from a text datafile

Public Sub load_list_box_two(MyList As ListView, MyFile As String)
MyList.ListItems.Clear
MyList.View = lvwReport
Open MyFile For Input As #1
  
  Input #1, one$, two$
  X = MyList.ColumnHeaders.Add(, , one$)
  X = MyList.ColumnHeaders.Add(, , two$)
  Do Until EOF(1)
    Input #1, one$, two$
    X = MyList.ListItems.Add(, , one$).ListSubItems.Add(, , two$)
  Loop
Close #1
End Sub

Download this snippet    Add to My Saved Code

Add to a ListView control on the fly from a text datafile Comments

No comments have been posted about Add to a ListView control on the fly from a text datafile. Why not be the first to post a comment about Add to a ListView control on the fly from a text datafile.

Post your comment

Subject:
Message:
0/1000 characters