Note that there are some explanatory texts on larger screens.

plurals
  1. POBindingSource/DataGridView interaction
    primarykey
    data
    text
    <p>I cannot understand why my DataGridView keeps on being empty (no rows, no autogenerated columns):</p> <pre><code>BindingList&lt;MyObject&gt; bList = new BindingList&lt;MyObject&gt;(); fileStream.Position = 0; MyObject.Deserialize(fileStream).ForEach( j =&gt; bList.Add(j)); this.bindingSource1.SuspendBinding(); this.dataGridView1.Columns.Clear(); this.dataGridView1.AutoGenerateColumns = true; this.dataGridView1.Enabled = false; this.dataGridView1.Invalidate(); this.bindingSource1.DataSource = bList; this.dataGridView1.DataSource = bindingSource1; this.bindingSource1.ResumeBinding(); this.dataGridView1.Enabled = true; this.dataGridView1.Refresh(); </code></pre> <p>where MyObject is defined as</p> <pre><code>public class MyObject { public DateTime CreationDate; public string CreationId; public static List&lt;MyObject&gt; Deserialize(Stream s) { XDocument xml = XDocument.Load(s); var ps = from p in xml .Descendants("p") .Descendants("object") select new MyObject { CreationId = p.Attribute("creationid").Value }; return ps.ToList(); } } </code></pre> <p>In addition if I explicitily set columns as below, rows are added to the grid but they are all empty</p> <pre><code>DataGridViewTextBoxColumn dc = new DataGridViewTextBoxColumn(); dc.DataPropertyName = "CreationDate"; dc.HeaderText = "CreationDate"; dc.Name = "CreationDate"; dc.Visible = true; dc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dataGridView1.Columns.Add(dc); dc = new DataGridViewTextBoxColumn(); dc.DataPropertyName = "CreationId"; dc.HeaderText = "CreationId"; dc.Name = "CreationId"; dc.Visible = true; dc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dataGridView1.Columns.Add(dc); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload