$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Control
Powerful GridView C#.NET control supports data binding to various data sources
Home > WinForms UI Controls > User Manual > Binding to Binding List in C#

GridView Data Binding to BindingList

The BindingList is a generic list type. The Kettic DataGridView component is capable of binding to Generic Lists. The BindingList provides additional binding support to Generic List. When we are going to bind the GridView component to a generic list, the BindingList will offers additional control over list items to edit, remove or add. The BindingList also surfaces C# events notifying users of GridView as any changes happened to the Bindinglist.

How to Bind GridView to BindingList

In the example showing as following, we are going to create a MyObject list, initializing the BindingList and assigning the BindingList to the DataSource property of the GridView control. We are going to use the ListChangedEventHandler in the example below to report the type changes occurring, the item new index and content.
C# code for creating C# class for binding GridView .NET component to BindingList

public class MyObject
{
public MyObject(int myInt, string myString)
{
_myInt = myInt;
_myString = myString;
}
private int _myInt;
public int MyInt
{
get { return _myInt; }
set { _myInt = value; }
}
private string _myString;
public string MyString
{
get { return _myString; }
set { _myString = value; }
}
}
C# code for binding GridView .NET component to BindingList to BindingList

private BindingList<MyObject> myList;
private void Form1_Load(object sender, EventArgs e)
{
myList = new BindingList<MyObject>();
myList.Add(new MyObject(1, "Tables"));
myList.Add(new MyObject(2, "Cups"));
myList.Add(new MyObject(3, "Chairs"));
myList.Add(new MyObject(4, "Bottles"));
myList.Add(new MyObject(5, "Spoons"));
myList.RaiseListChangedEvents = true;
myList.ListChanged += new ListChangedEventHandler(myList_ListChanged);
ketticGridView1.DataSource = myList;
}
void myList_ListChanged(object sender, ListChangedEventArgs e)
{
MessageBox.Display(e.ListChangedType.ToString() + ": at index: " + e.NewIndex.ToString() + ", \"" + myList[e.NewIndex].MyString + "\"");
}
private void ketticButton1_Click(object sender, EventArgs e)
{
myList.Add(new MyObject(6, "DiningRoom"));
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls