How do I databind a DataGridView column to a property on another referenced
object? That is, I want to bind to "Parent.Name" where Parent is a property
that references another object.

I know this can be done when databinding TextBoxes. Surely it can also be
done with grid columns.

The following example should illustrate my problem:


using System.Windows.Forms;

namespace MyTest {
class MyTestForm : Form {
public MyTestForm() {
DataGridView grid = new DataGridView();
DataGridViewColumn col = new DataGridViewTextBoxColumn();
col.HeaderText = "Parent.Name";
col.DataPropertyName = "Parent.Name";
grid.Columns.Add(col);
col = new DataGridViewTextBoxColumn();
col.HeaderText = "Name";
col.DataPropertyName = "Name";
grid.Columns.Add(col);
grid.DataSource = new BindingSource(new Child[] {
new Child(new Parent("dad"), "son")
}, null);
this.Controls.Add(grid);
}
}

class Parent {
private string _Name;

public Parent(string Name) {
_Name = Name;
}

public string Name {
get { return _Name; }
set { _Name = value; }
}
}

class Child {
private Parent _Parent;
private string _Name;

public Child(Parent Parent, string Name) {
_Parent = Parent;
_Name = Name;
}

public Parent Parent {
get { return _Parent; }
}

public string Name {
get { return _Name; }
set { _Name = value; }
}
}
}


Nathan