title: Winform Datagridview doesn't display data
body: <p>Binding data is not working for my datagridview.</p>
  
  <p>Here is .cs file</p>
  
  <pre><code>using FirebirdSql.Data.FirebirdClient;
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Diagnostics;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace Magacin
  {
      public partial class AnalizaPartneraGlobal : Form
      {
          List&lt;Int_String&gt; partneri = Komercijalno.Partner.Lista();
          List&lt;NeaktivniPartner&gt; neaktivniPartneri = new List&lt;NeaktivniPartner&gt;();
          public AnalizaPartneraGlobal()
          {
              InitializeComponent();
              dataGridView1.AutoGenerateColumns = true;
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              foreach(Int_String partner in partneri)
              {
                  double danaBezProdaje = (DateTime.Today - Komercijalno.Partner.PoslednjaKupovina(partner._int)).TotalDays;
                  if ( danaBezProdaje &gt; 31)
                  {
                      NeaktivniPartner np = new NeaktivniPartner();
                      np.ppid = partner._int;
                      np.naziv = partner._string;
                      np.danaBezKupovine = danaBezProdaje;
                      neaktivniPartneri.Add(np);
                  }
              }
              dataGridView1.DataSource = M.List.ConvertToDataTable(neaktivniPartneri);
              dataGridView1.Refresh();
          }
      }
  
      public class NeaktivniPartner
      {
          public int ppid;
          public string naziv;
          public double danaBezKupovine;
      }
  }
  </code></pre>
  
  <p>As you can see i only have <code>button</code> and <code>dataGridView</code></p>
  
  <p>If i recall earlier i have been doing <code>dataGridView.dataSource = myGenericList;</code> worked perfect but for some reason now it is not working so i tried converting it to <code>DataTable</code> but still not working. Then i added <code>AutogenerateColumns</code> and still not displaying any data or columns. And after that tried adding <code>Refresh()</code> but still nothing.</p>
  
  <p>In debugger it shows that datagridview has rows inside it:
  <a href="https://i.stack.imgur.com/nwOJj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nwOJj.png" alt="enter image description here"></a></p>
  
  <p>Beside this i tried:</p>
  
  <ul>
  <li>Deleting datagridview and do everything again</li>
  <li>Close VS and open it again</li>
  <li>Tried doing it with <code>BindingList</code></li>
  <li>Tried binding list to datasource directly</li>
  </ul>
  
  <p>Code behind <code>ConvertToDataTable</code></p>
  
  <pre><code>public static DataTable ConvertToDataTable&lt;T&gt;(IList&lt;T&gt; data)
  {
          PropertyDescriptorCollection properties =
             TypeDescriptor.GetProperties(typeof(T));
          DataTable table = new DataTable();
          foreach (PropertyDescriptor prop in properties)
              table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
          foreach (T item in data)
          {
              DataRow row = table.NewRow();
              foreach (PropertyDescriptor prop in properties)
                  row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
              table.Rows.Add(row);
          }
          return table;
      }
  </code></pre>