Results 1 to 4 of 4

Thread: Help with organized list view

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    180

    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?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help with organized list view

    This should get you started at least
    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim myDir As New System.IO.DirectoryInfo("c:\")
    3.         For Each myFile As System.IO.FileInfo In myDir.GetFiles("*.*")
    4.             Dim lvwItem As ListViewItem = ListView1.Items.Add(myFile.Name)
    5.             lvwItem.SubItems.Add(Convert.ToString(myFile.LastAccessTime))
    6.             lvwItem.SubItems.Add(Convert.ToString(myFile.Length))
    7.         Next
    8. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    180

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width