Dev GridView bindings list<t>, BindingList <T>, BindingSource

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.