Lovely DataGridView

Mircosoft did a create job with the DataGridView in .Net 2.0. It’s so easy to display you own data. All you need is a IList implementation. The List< T > was the first which comes up in my mind. And it’s works! All public properties are automaticly added to the view.
As special highlight you can – of course – use the attribute BrowsableAttribute to hide public properties which you want not to show up in the view. Great stuff 😉
Just open a new project add a DataGridView and try this class as DataSource. You’ll love it.

[sourcecode lang=“c#“] class Person
string _vorname;
string _nachname;
string _town;

public string Vorname
get { return _vorname; }
set { _vorname = value; }

public string Nachname
get { return _nachname; }
set { _nachname = value; }

public string Town
get { return _town; }
set { _town = value; }

public Person( string vorname, string nachname, string town )
_vorname = vorname;
_nachname = nachname;
_town = town;


Main Form[sourcecode lang=“c#“]List< Person > l = new List< Person >();private void Form1_Load(object sender, EventArgs e)
l.Add(new Person(„Roger“, „Sennert“, „City“));
l.Add(new Person(„Test“, „Main“, „Village“));
l.Add(new Person(„Steve“, „Miller“, „Village“));

dataGridView1.DataSource = l;