I'm trying to bind a DataGridView to a reflected object array. The header columns bind fine, the correct name is displayed and seven rows are displayed, the issue is the rows are empty. When I check the databound items it looks fine. It shows that it's the correct reflected model and the values.
This is the snippet I've got so far.
private void comboBoxTables_SelectedIndexChanged(object sender, EventArgs e)
{
var type = (Type)(this.comboBoxTables.SelectedItem as ComboBoxItem).Value;
object[] result = this.DataLoader.Get(type);
dataGridView1.DataSource = result;
this.dataGridView1.Columns.Clear();
var properties = type.GetProperties();
foreach (var property in properties)
{
this.dataGridView1.Columns.Add(property.Name, property.Name);
this.dataGridView1.Columns[property.Name].DataPropertyName = property.Name;
}
this.dataGridView1.Refresh();
}
This snippet:
object[] result = this.DataLoader.Get(type);
Fetches the data from a dictionary containing the reflected values as an object array.
I've tried using a binding source instead and some other ugly hacks, but I can't get the rows to display any data.
Any help is greatly appreciated, thank you in advance.
Aucun commentaire:
Enregistrer un commentaire