Results 1 to 5 of 5

Thread: [RESOLVED] Filter a list view

  1. #1

    Thread Starter
    Lively Member Iain Wicks's Avatar
    Join Date
    Jun 2005
    Location
    Tring, Hertfordshire
    Posts
    88

    Resolved [RESOLVED] Filter a list view

    Hello,
    is it possible to filter a listview to show only bmp or jpeg files that exist in the source directory.

    Thanks

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

    Re: Filter a list view

    A ListView displays what you put in it. If you only want to display certain files then only put thise files in in the first place. I assume that you are calling GetFiles to get the file list. GetFiles is overloaded and allows you to specify a filter, so if you use that then you will only get the files you want in the first place.

    Having said that, the ExtendedListView in the free Quantum Windows Forms Components library (see my signature for link) supports complex data-binding. If they have created that to mimic the way it works with a DataGrid then you could use a DataTable and set its DefaultView.RowFilter property to filter what's displayed.
    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

  3. #3

    Thread Starter
    Lively Member Iain Wicks's Avatar
    Join Date
    Jun 2005
    Location
    Tring, Hertfordshire
    Posts
    88

    Re: Filter a list view

    Thanks for the great tip.
    I am now using getfiles("*.jpg")
    Which works great ...BUT
    if i try
    GetFiles("*.jpg *.jpeg") I get nothing
    or
    GetFiles("*.jpg *.jpeg") I get an error

    Could you tell me the proper syntax for multiple file types.

    Basically I need to look for all the usual image file types.

    Thanks

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

    Re: Filter a list view

    The proper syntax is to make the call multiple times for multiple filters. You shouldn't have to worry about combining and sorting the arrays because the ListView can do that for you, but you can do it yourself if you want.
    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

  5. #5

    Thread Starter
    Lively Member Iain Wicks's Avatar
    Join Date
    Jun 2005
    Location
    Tring, Hertfordshire
    Posts
    88

    Re: Filter a list view

    jmcilhinney ... you've helped a lot.

    I've got it now
    many thanks

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