title: Add a ComboBox To ListView Column in a Row?
body: <p>Sometimes I want to add text to a ListView in an items column in a specific row.<br />
  Sometimes want to show a ComboBox for a user to select an entry.</p>
  <p>Do I need to create a class derived from the ListView control?</p>
  <p>Here is what I have so far:</p>
  <pre><code>ListView lv = new ListViewEx();
  lv.Size = new Size(300, 300);
  this.Controls.Add(lv);
  lv.View = View.Details;
  lv.FullRowSelect = true;
  lv.Scrollable = true;
  
  lv.Columns.Add(&quot;Column 1&quot;);
  lv.Columns.Add(&quot;Column 2&quot;);
  lv.Columns.Add(&quot;Column 3&quot;);
  lv.Columns.Add(&quot;Column 4&quot;);
  
  string[] testresult = new string[] { &quot;Pass&quot;, &quot;Pass&quot;, &quot;Pass&quot;, &quot;Pass&quot; };
  testresult = new string[] { &quot;Pass&quot;, &quot;Pass&quot;, &quot;Pass&quot;, &quot;Pass&quot; };
  ListViewItem itm;
  itm = new ListViewItem(testresult);
  lv.Items.Add(itm);
  
  // need to add a ComboBox in the 4th column of this list view item and a way to get the value selected from it
  testresult = new string[] { &quot;Pass&quot;, &quot;Pass&quot;, &quot;Pass&quot;, &quot;Click To Enter Pass/Fail Result&quot; };
  itm = new ListViewItem(testresult);
  lv.Items.Add(itm);
  
      private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
      {
          var lv = sender as ListView;
          var subItem = lv.HitTest(lv.PointToClient(MousePosition)).SubItem;
  
          if (subItem != null &amp;&amp; e.SubItem == subItem)
          {
              using (var brush = new SolidBrush(SystemColors.Highlight))
              {
                  e.Graphics.FillRectangle(brush, e.SubItem.Bounds);
              }
  
              if (e.SubItem.Text == &quot;Click To Enter Pass/Fail Result&quot;)
              {
                  TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font,
                                        e.Bounds, SystemColors.HighlightText, flags);
              }
              else
              {
                  TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font,
                                        e.Bounds, SystemColors.HighlightText, flags);
              }
          }
          else
          {
              e.DrawDefault = true;
          }
      }
  </code></pre>