Today, I heard colleagues dealing with data structures deliberately handled for BINDINGLIST<T>, which is said to be directly bound to the dev GridView, and then tested:
1, in the dev GridView added three columns, three columns of fieldname corresponding to the Formitem class corresponding: Itemkey, Name, Enable
The specific class code is as follows:
public class formitem{//<summary>///logo/// </summary> public string Itemkey { get; Set; } <summary>///// </summary> public string name { get; Set; } <summary>///if available/// </summary> public bool Enable { get; set; }}
3. Add a Buntton button event to the form, adding the Click event,The Click event Populates list<t>, BindingList <T>, BindingSource, and tests for binding:
bindinglist<formitem> itemsbindinglist = new bindinglist<formitem> (); list<formitem> itemslist = new list<formitem> (); BindingSource bs = new BindingSource (); private void Simplebutton1_click (object sender, EventArgs e) {for (int i = 0; i < ten; i++) {FormItem fi = new FormItem (); Fi. Itemkey = i.ToString (); Fi. Name = Guid.NewGuid (). ToString (); if (i% 2 = = 0) {fi. Enable = true; } else {fi. Enable = false; } itemsbindinglist.add (FI); Itemslist.add (FI); Bs. Add (FI); }//this.gridcontrol1.datasource = Itemsbindinglist; This.gridControl1.DataSource = itemslist; This.gridControl1.DataSource = BS; }
4, through the test found list<t>, BindingList <T>, BindingSource can be bound to the dev GridView
5. the friend who used Dev GridView should know that after binding a DataTable to the Dev GridView, the changes on the GridView will be synchronized to the DataTable, then the problem comes to dev GridView Binding list<t>, BindingList <T>, BindingSource will not sync it?
The Cellvaluechanged event of the GridView is added, and the variables itemsbindinglist, Itemslist, and BS are monitored in this event, and modifications are also synchronized.
Small bet
BindingSource First time use, there is wrong place, also please advise !
Demo Download: Click to open link
data source can be any type that implements one of the following interfaces:
ilist interface, including one-dimensional arrays. list<t>, wait!
ilistsource interfaces, such as,datatable and DataSet classes.
ibindinglist interfaces, such as the,bindinglist class.
IBindingListView interface, for example, the BindingSource class.
Copyright: jiankunking Source: http://blog.csdn.net/jiankunking This article is copyright to the author and Csdn, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original connection.
Dev GridView bindings list<t>, BindingList <T>, BindingSource