Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Bind ArrayList with object memeber to DataGridView
 

Bind ArrayList with object memeber to DataGridView

I wish to bind an ArrayList of data objects to a DataGridView. If the ArrayList contains objects of simple types no problem the grid is populated as expected with public property names.

However, if the objects of the ArrayList themselvescontain an object member, the object is representing in the grid by a single 'object' column. How do I implement Databinding to expand the member objects such as the "employee" objects shown below?

BindingSource bs = new BindingSource(data,"Teams");
this.dataGridView1.DataSource = null;
this.dataGridView1.DataSource = bs;
this.dataGridView1.Refresh();
class Team
{
private Employee leader;
private Employee runt;
private string name;
//Public Properties
}
class Employee
{
private string name;
private string id;
//Public Properties
}

As a newbie a code example would be greatly appreciated. Thank you.

missbluebar  Thursday, September 21, 2006 10:05 AM
I wouldadd aToString method for the Employee class to show all of my properties.
Ken Tucker  Thursday, September 21, 2006 11:01 AM
I wouldadd aToString method for the Employee class to show all of my properties.
Ken Tucker  Thursday, September 21, 2006 11:01 AM

Hi Ken,

That sounds like a great idea but I'm not quite sure what you're getting at.

Could you expand on that idea a little =D

Thnx a bunch,

CS

cs96ai  Friday, April 13, 2007 6:23 AM

Please see my related question on codeproject.com

How to bind ArrayList with DataGridView ?

Harminder Singh  Friday, May 11, 2007 6:46 PM

You can use google to search for other answers

Custom Search

More Threads

• Tableadapter delete won't update to database but insert will?
• Parent-child relation using datagridview
• Bind file to Grid
• combobox selectedvalue vs text question
• When to dispose TableAdapter?
• How can I emmbed a treeview control into DataGridView
• Get the position of an DataGridViewTextBoxCell
• Problems Filtering a Bindingsource
• Winforms Datagrid Vs DataRow BeginEdit
• Column spanning cell editor