title: Copy subitem from listview to clipboard
body: <p>I have a program that allows a user to upload information to a database for code debugging. The initial code is uploaded, then displayed in a list view. I am trying to figure out a way to copy a single cell of data, specifically the "Code" cell, so when a user clicks on the cell they can copy just that code, not the whole row.</p>
  
  <p><strong>I have tried using labeledit, but this allows editing on the whole form which isn't the functionality im looking for. I want locked cells for everything but the code cells, but then only allowing Copying from that cell.</strong></p>
  
  <p>Here is how my list view is prepared.</p>
  
  <p><strong>InitializeListView</strong></p>
  
  <pre><code> private void InitializeListView()
          {
              // Set the view to show details.
              lbxBugged.View = View.Details;
  
  
              // Allow the user to rearrange columns.
              lbxBugged.AllowColumnReorder = true;
  
              // Select the item and subitems when selection is made.
              lbxBugged.FullRowSelect = true;
  
              // Display grid lines.
              lbxBugged.GridLines = true;
  
              // Sort the items in the list in ascending order.
              lbxBugged.Sorting = SortOrder.Ascending;
  
              // Attach Subitems to the ListView
              lbxBugged.Columns.Add("ID", 70, HorizontalAlignment.Left);
              lbxBugged.Columns.Add("Code", 300, HorizontalAlignment.Left);
              lbxBugged.Columns.Add("Description", 200, HorizontalAlignment.Left);
              lbxBugged.Columns.Add("Author", 120, HorizontalAlignment.Left);
          }
  </code></pre>
  
  <p><strong>PopulateListView</strong></p>
  
  <pre><code>public void populateListView()
  {
      lbxBugged.Items.Clear();
      SqlCeCommand cm = new SqlCeCommand("SELECT Bug_ID, Bug_Code, Bug_Description, Bug_Author FROM tblBugs ORDER BY Bug_ID ASC", mySqlConnection);
  
      try
      {
          mySqlConnection.Open();
          SqlCeDataReader dr = cm.ExecuteReader();
          while (dr.Read())
          {
              ListViewItem item = new ListViewItem(dr["Bug_ID"].ToString());
              item.SubItems.Add(dr["Bug_Code"].ToString());
              item.SubItems.Add(dr["Bug_Description"].ToString());
              item.SubItems.Add(dr["Bug_Author"].ToString());
  
              lbxBugged.Items.Add(item);
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, "Error");
      }
  
  
  }
  </code></pre>