title: how to check the list view items when we are using groups in list view
body: <p>how to check the list view items when we are using list view group s...</p>
  
  <p>I have list view in that i am using two groups ....</p>
  
  <p>If i click on the list view first group item then  click on the list view second group item </p>
  
  <p>I want to do something ...</p>
  
  <p>for that i have done below ...</p>
  
  <pre><code>private void lstviewCatgeories_SelectedIndexChanged(object sender, EventArgs e)
  {
      var selectedItems = lstviewCatgeories.SelectedItems.Cast&lt;ListViewItem&gt;();
      var passed = (selectedItems
          .Select(l =&gt; l.Group.Name)
          .Distinct()
          .Count() == 2 &amp;&amp; selectedItems.Count() == 2
      );
      if (passed)
      {
          var categoryItem = selectedItems
              .Where(l =&gt; l.Group.Name.ToLower() == "catgories")
              .Single();
          var priceItem = selectedItems
              .Where(l =&gt; l.Group.Name.ToLower() == "pricesrangegroup")
              .Single();
  
  
      // do something
  
  
      }
  }
  </code></pre>
  
  <p>but the control does not goes in to if condition even if i select the first item in group 1
  and then i select the second item in second group  </p>
  
  <p>but it does not working ..</p>
  
  <p>would any one pls help on this...</p>
  
  <p>many thanks</p>
  
  <p><strong>EDIT :</strong> I am getting count 1 at this line    <strong>lstviewCatgeories.SelectedItems</strong></p>
  
  <p>would any one suggest any alternative solution for this.....</p>