title: How to add a button to a column or subitem in a ListView in WinForms?
body: <p>I am having a terrible time trying to figure out how to list a button with a value on a listview to go with each value.</p>
  
  <p><a href="https://i.stack.imgur.com/gmlFP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gmlFP.png" alt="What I currently have"></a></p>
  
  <p>I need to replace all of the add/edit string values with Buttons. The original assignment was for a listbox but I figured that the only way too accomplish this is through subitems from listview items. Thanks.</p>
  
  <pre><code> public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
          this.DefinedClassesLb.Columns.Add("Samples", 90);
          this.DefinedClassesLb.Columns.Add("AddEdit", 60);
          this.DefinedClassesLb.Columns.Add("Delete", 45);
  
          ListViewItem item = new ListViewItem("1");
          item.SubItems.Add("add/edit");
          item.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item);
  
          ListViewItem item2 = new ListViewItem("2");
          item2.SubItems.Add("add/edit");
          item2.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item2);
  
          ListViewItem item3 = new ListViewItem("3");
          item3.SubItems.Add("add/edit");
          item3.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item3);
  
          ListViewItem item4 = new ListViewItem("4");
          item4.SubItems.Add("add/edit");
          item4.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item4);
  
          ListViewItem item5 = new ListViewItem("5");
          item5.SubItems.Add("add/edit");
          item5.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item5);
  
          ListViewItem item6 = new ListViewItem("6");
          item6.SubItems.Add("add/edit");
          item6.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item6);
  
          ListViewItem item7 = new ListViewItem("7");
          item7.SubItems.Add("add/edit");
          item7.SubItems.Add("x");
          this.DefinedClassesLb.Items.Add(item7);
  
          this.DefinedClassesLb.View = View.Details;
          this.DefinedClassesLb.HeaderStyle = ColumnHeaderStyle.None;
  
      }
  }
  </code></pre>