title: How do I create EventHandler for ItemChecked in ListView?
body: <p>I am trying to delete each checked item on my ListView item in detailed list. I don't want to delete entry while checking, but pass a value to my button which will use a value to delete entry.</p>
  
  <p>I have played with it a little but I came across few problems. First of all, I cannot create an event handler by doing this: <code>lvPC.ItemChecked += new EventHandler(CheckedState);</code> which causes error: <code>No overload for 'CheckedState' matches delegate 'System.EventHandler'</code>.</p>
  
  <p>Second, how can I get get the ID of the item? By saying this I mean that each added entry has it's own ID, but it isn't added to the table view. Meaning how do I decide which ID should be removed?</p>
  
  <pre><code>private void CheckedState
      (object sender, System.Windows.Forms.ItemCheckEventArgs e)
  {
      ListView.CheckedListViewItemCollection 
          checkedItems = lvPC.CheckedItems;
  
      string items;
  
      foreach (ListViewItem item in checkedItems)
      {
          items = item + ", "; 
          MessageBox.Show(items);
      }
  
      if (e.CurrentValue == CheckState.Unchecked)
      {
      }
      else if ((e.CurrentValue == CheckState.Checked))
      {
      }
  }
  </code></pre>
  
  <p>This is how I am inserting data into 3 different ListView:</p>
  
  <pre><code>using (OleDbDataReader read = command.ExecuteReader())
  {
      // Checking if there is any data in the file.
      if (read.HasRows)
      {
          // Reading information from the file.
          while (read.Read())
          {
              if (security.DecryptAES(read.GetString(1), 
                  storedAuth.Password, storedAuth.UserName) 
                      == "PC Password")
              {
                  PC = new ListViewItem("");
                  PC.SubItems.Add(security.DecryptAES
                      (read.GetString(5), storedAuth.Password, 
                          storedAuth.UserName));
                  PC.SubItems.Add(security.DecryptAES
                      (read.GetString(6), storedAuth.Password, 
                          storedAuth.UserName));
  
                  lvPC.Items.Add(PC);
              }
              else if (security.DecryptAES(read.GetString(1), 
                  storedAuth.Password, storedAuth.UserName) 
                      == "Web Site Password")
              {
                  Web = new ListViewItem("");
                  Web.SubItems.Add(security.DecryptAES
                      (read.GetString(2), storedAuth.Password, 
                          storedAuth.UserName));
                  Web.SubItems.Add(security.DecryptAES
                      (read.GetString(5), storedAuth.Password, 
                          storedAuth.UserName));
                  Web.SubItems.Add(security.DecryptAES
                      (read.GetString(6), storedAuth.Password, 
                          storedAuth.UserName));
  
                  lvWeb.Items.Add(Web);
              }
              else if (security.DecryptAES(read.GetString(1), 
                  storedAuth.Password, storedAuth.UserName) 
                      == "Serial Code")
              {
                  Serial = new ListViewItem("");
                  Serial.SubItems.Add(security.DecryptAES
                      (read.GetString(3), storedAuth.Password, 
                          storedAuth.UserName));
                  Serial.SubItems.Add(security.DecryptAES
                      (read.GetString(4), storedAuth.Password, 
                          storedAuth.UserName));
  
                  lvSerialCode.Items.Add(Serial);
              }
          }
      }
  }
  </code></pre>