Using LINQ to see if Item already exists in listview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gaz

    Using LINQ to see if Item already exists in listview

    Im trying to use c# and linq to simplfy searching through a listview
    but cannot get it to work can anyone help?


    here is what i got so far which doesnt work.



    var qry = from L in listviewname.it ems.all

    where l.item.value == "123"

    Select L.item.value;



    Thanks Gary
  • Gaz

    #2
    Re: Using LINQ to see if Item already exists in listview

    ok i will start again...

    Im trying to learn LINQ and im not sure if im going about this in the
    correct method.

    I want to query all the items in the listview collection where the
    item key value in the collection is equal to what i tell it..

    This is my code..

    var qry = from itm in uListSelected.I tems
    where itm.key == "1"
    Select itm.key;

    foreach (var Result in qry)
    {
    return true;
    }

    Is this bit more helpful?

    Comment

    • Gaz

      #3
      Re: Using LINQ to see if Item already exists in listview

      its to replace this


      foreach(Infragi stics.Win.Ultra WinListView.Ult raListViewItem Itm in
      uListSelected.I tems)
      {

      if (KeyID == Convert.ToStrin g(Itm.Key))
      {
      return true;

      }

      }

      Comment

      Working...