Rauland
Jun 7th, 2007, 11:11 AM
Hi
Suppose I have a Class Person, with a property "Surname".
I have a dataTable such as:
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("Surname",typeof(Person));
dt.Columns.add(dc);
Create an Instance of Person:
Person prs = new Person();
prs.Surname = "Rauland";
I now, create a dataRow:
DataRow dr = dt.CreateRow();
dr["Surname"] = prs;
dt.rows.add(dr);
I now use this dataTable as a dataSource to a dataGridView, named dbTest;
This grid has a column named, "Surname".
And have set the DataPropertyName to "Surname".(Meaning that it will display in this column the DataTableīs column with name "Surname")
dbTest.DataSource = dt;
The only thing it displays the type of object, in this case, Person.
Is there a way to set what in other controls is called "DisplayMember", the DataTablesīs column named "Surname", to display the Personīs property "Surname".
Thanks!!
Suppose I have a Class Person, with a property "Surname".
I have a dataTable such as:
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("Surname",typeof(Person));
dt.Columns.add(dc);
Create an Instance of Person:
Person prs = new Person();
prs.Surname = "Rauland";
I now, create a dataRow:
DataRow dr = dt.CreateRow();
dr["Surname"] = prs;
dt.rows.add(dr);
I now use this dataTable as a dataSource to a dataGridView, named dbTest;
This grid has a column named, "Surname".
And have set the DataPropertyName to "Surname".(Meaning that it will display in this column the DataTableīs column with name "Surname")
dbTest.DataSource = dt;
The only thing it displays the type of object, in this case, Person.
Is there a way to set what in other controls is called "DisplayMember", the DataTablesīs column named "Surname", to display the Personīs property "Surname".
Thanks!!