Help with organized list view
I'm in need of some pointers.
I'm trying to create a simple data base program of sorts. I have a data set that contains file information (simple array "DATA(x,x)"). So each row is a different file, and each column is different bits of information about that file. I'm looking at trying to find a way to display this information.
Ex. When you use the windows "Search for files" app, you get a listview with all the files found and other information about the file. And with this you can organize by date, type, size, etc. I'm looking to do the same thing with my data set. How would one go about doing it in vb.net?
Re: Help with organized list view
This should get you started at least
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myDir As New System.IO.DirectoryInfo("c:\")
For Each myFile As System.IO.FileInfo In myDir.GetFiles("*.*")
Dim lvwItem As ListViewItem = ListView1.Items.Add(myFile.Name)
lvwItem.SubItems.Add(Convert.ToString(myFile.LastAccessTime))
lvwItem.SubItems.Add(Convert.ToString(myFile.Length))
Next
End Sub
Re: Help with organized list view
Quote:
Originally Posted by Hack
This should get you started at least....
Well not quite what I was looking for. I'm not really working with files, more like a previously generated txt file that contains information about files (and then some). But I see what your getting at.
I have no issues setting up list boxes and list views, I just dont know how to format them to resemble the list views windows uses (similar to the "search for files" example above) with all the features of sorting, and placing data in their respective location in the view.
Re: Help with organized list view
Set the View to Details and add a column for each property you want to display. You then add an item for each row and a subitem to that for each additional column. For sorting you should read the documentation for the ListView.Sort method, which shows you how to implement your own IComparer.