title: C#: how to show list from custom class objects in a combobox
body: <p>this is my class:</p>
  
  <pre><code>namespace LAN_index_program
  {
  public class LAN_object
  {
      public string Name { get; set; }
      public LAN_object(
          DEVICETYPE a_type,
          string a_deviceName,
          string a_deviceManufacure,
          string a_deviceOwner,
          string a_deviceIp,
          string a_deviceMac,
          DateTime a_deviceInstalationDate
          )
      {
          m_deviceType = a_type;
          m_deviceName            = a_deviceName;
          m_deviceManufacure      = a_deviceManufacure;
          m_deviceOwner           = a_deviceOwner;
          m_deviceIp              = a_deviceIp;
          m_deviceMac             = a_deviceMac;
          m_deviceInstalationDate = a_deviceInstalationDate;
          Name = a_deviceName;
      }
  
  //        public string a_deviceName
  //        {
  //            get
  //            {
  //                return m_deviceName;
  //            }
  //        }
  
      public enum DEVICETYPE
      {
          Router,
          Switch,
          Access_point,
          Laptop,
          Phone,
          Computer
      };
  
      public string toString()
      {
          string lan_onbjectstring = "";
  
          lan_onbjectstring = m_deviceType.ToString() + "\r\n";
          lan_onbjectstring +=  m_deviceName + "\r\n";
          lan_onbjectstring += m_deviceManufacure + "\r\n";
          lan_onbjectstring += m_deviceOwner + "\r\n";
          lan_onbjectstring += m_deviceIp + "\r\n";
          lan_onbjectstring += m_deviceMac + "\r\n";
          lan_onbjectstring += m_deviceInstalationDate.ToShortDateString() + "\r\n";
  
          return lan_onbjectstring;
      }
  
      public override string ToString()
      {
          return m_deviceName;
      }
  
      DEVICETYPE m_deviceType;
      string m_deviceName;
      string m_deviceManufacure;
      string m_deviceOwner;
      string m_deviceIp;
      string m_deviceMac;
      DateTime m_deviceInstalationDate;
  }
  }
  </code></pre>
  
  <p>and this is the code i thought would do it:</p>
  
  <pre><code>m_listLanObjects = new List&lt;LAN_object&gt;();
  
          comboBox1.DataSource = m_listLanObjects;
          comboBox1.DisplayMember = "Name";
          comboBox1.ValueMember = null;
  </code></pre>
  
  <p>every time i add an new LAN_object to the list i reset the datasource to m_listlanobjects. but the combobox is not filling up.</p>
  
  <pre><code>namespace LAN_index_program
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
          m_listLanObjects = new List&lt;LAN_object&gt;();
  
          comboBox1.DataSource = m_listLanObjects;
          comboBox1.DisplayMember = "Name";
          comboBox1.ValueMember = null;
  
      }
  
  
      public void AddLanObject(LAN_object a_newLanObject, LAN_object a_oldlanobject, bool New = true)
      {
          if (New)
          {
              m_listLanObjects.Add(a_newLanObject);
          }
          else
          {
              int index = m_listLanObjects.IndexOf(a_oldlanobject);
              m_listLanObjects.RemoveAt(index);
              m_listLanObjects.Insert(index, a_newLanObject);
          }
          richTextBox1.Text = "";
          richTextBox1.Text = listToString();
          comboBox1.DataSource = m_listLanObjects;
      }
  }
  }
  </code></pre>
  
  <p>i would like to choose an lan_object from it's name (m_deviceName). and at the press of a button want to use that specific Lan_object in further functionality.</p>
  
  <p>hope someone can help, google for once did not help.</p>