Problems with BindingList<>

I am having some trouble with the BindingList<>

There does not seem to be a simple means of defining the sort order of the columns in theunderlying type.  I would have assumed that there would be some form of attribute based approach to this. 

Here is a small sample of my experiments: 

    public class Node
        private string _Name;
        public string Name{ get{return _Name;} set{_Name = Name;}}

        private int _Age;

        public int Age
            get { return _Age; }
            set { _Age = value; }

        public Node(string name, int age)
            _Name = name;
            _Age = age;

    public class BindingClass : BindingList<Node>
        public BindingClass()


        private BindingClass _Data = new BindingClass();
        public Form1()
            _Data.Add(new Node(“Tom”,50));
            _Data.Add(new Node(“Dick”, 40));
            _Data.Add(new Node(“Harry”, 30));
            dataGridView1.DataSource = _Data;
            dataGridView1.Columns[0].DataPropertyName = “Name”;
            dataGridView1.Columns[0].HeaderText = “First Name”;
            dataGridView1.Columns[1].DataPropertyName = “Age”;
            dataGridView1.Columns[1].HeaderText = “Age”;

This seems to be the least code needed to define the column order, titles and names.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s