title: DataGridViewColumn.DataPropertyName Property
body: <p>I have a DataGridView control and I want to populate it with data.</p>
  
  <p>I use DataSource property</p>
  
  <pre><code>// dgvDealAsset is DataGridView
          private void DealAssetListControl_Load(object sender, EventArgs e)
          {
              dgvDealAssets.AutoGenerateColumns = false;
              dgvDealAssets.DataSource = DealAssetList.Instance.Values.ToList();
  }
  </code></pre>
  
  <p>Now problem number one. The class of my collection does not contain only simple types that I can map to columns using DataPropertyName. This is the class that is contained in collection.</p>
  
  <pre><code>class MyClass
  {
    public String Name;
    MyOtherClass otherclass;
  }
  
  class MyOtherClass
  {
   public String Name;
  }
  </code></pre>
  
  <p>Now I am binding properties of MyClass to columns</p>
  
  <pre><code>col1.DataPropertyName = "Name"  // Ok 
  col2.DataPropertyName = "otherclass" // Not OK - I will have empty cell
  </code></pre>
  
  <p>The problem is that I want to display otherclass.Name field. But if I try to write</p>
  
  <pre><code>col2.DataPropertyName = "otherclass.Name" 
  </code></pre>
  
  <p>I get empty cell.</p>
  
  <p>I tried to manually set the column</p>
  
  <pre><code>private void DealAssetListControl_Load(object sender, EventArgs e)
  {
      dgvDealAssets.AutoGenerateColumns = false;
      dgvDealAssets.DataSource = DealAssetList.Instance.Values.ToList();
  
  // iterate through rows and set the column manually
          foreach (DataGridViewRow row in dgvDealAssets.Rows)
          {
              row.Cells["Column2"].Value = ((DealAsset)row.DataBoundItem).otherclass.Name;
          }
  </code></pre>
  
  <p>But this foreach cycle takes about minute to complete (2k elements). How to solve this problem?</p>