Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. How to get filtered ListView items after Items.Filter is set

How to get filtered ListView items after Items.Filter is set

Scheduled Pinned Locked Moved WCF and WF
questiontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Chamria
    wrote on last edited by
    #1

    Hi, I have a ListView which is bound to a list of items of type Test. The list contains items with Id= 1 to 100. class Test { public int Id {get; set;} public string Name {get; set;} } Now I apply a filter as follows: listView.Items.Filter = delegate( object item ) { object idValue = item.GetType().GetProperty("Id").GetValue(item, null); if ( Convert.ToInt32(idValue) > 75 ) { return true; } else { return false; } }; On applying the filter now i can view only the last 25 rows in the ListView, which is fine. Now what i want to know is there a way to directly get a list of visible rows in the listview (the filtered rows). The ItemSource property returns all 100 rows always. How can i get the visible 25 rows?

    Pankaj Chamria, Software Developer.

    modified on Tuesday, April 14, 2009 4:20 AM

    S 1 Reply Last reply
    0
    • P Pankaj Chamria

      Hi, I have a ListView which is bound to a list of items of type Test. The list contains items with Id= 1 to 100. class Test { public int Id {get; set;} public string Name {get; set;} } Now I apply a filter as follows: listView.Items.Filter = delegate( object item ) { object idValue = item.GetType().GetProperty("Id").GetValue(item, null); if ( Convert.ToInt32(idValue) > 75 ) { return true; } else { return false; } }; On applying the filter now i can view only the last 25 rows in the ListView, which is fine. Now what i want to know is there a way to directly get a list of visible rows in the listview (the filtered rows). The ItemSource property returns all 100 rows always. How can i get the visible 25 rows?

      Pankaj Chamria, Software Developer.

      modified on Tuesday, April 14, 2009 4:20 AM

      S Offline
      S Offline
      sivaddrahcir
      wrote on last edited by
      #2

      You could keep track of the filtered items yourself, i.e. put items in a list whenever your filter is going to return True.

      Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups