Search Tools Links Login

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


Visual Basic 6, or VB Classic

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: est.dat")

Original Author: Blake Pell

Code

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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 104 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.