I am trying to understand the difference between the following 2 examples.
First, this is how I currently assign Data to a control in my WinForm App.
lkuCounty.Properties.DataSource = Person.CountyList();
lkuCounty.Properties.PopulateColumns();
lkuCounty.Properties.DisplayMember = "CountyName";
lkuCounty.Properties.ValueMember = "CountyID";
lkuCounty.Properties.Columns[0].Visible = false;
lkuCounty.Properties.Columns[2].Visible = false;
lkuCounty.Properties.Columns[3].Visible = false;
This seems to work though I'll admit that if it is slightly off I probably lack the experience to tell just by looking at the code. Also of note, Person.CountyList()
actually returns a DataTable
:\
Now how all of the examples I find seem to say I should do this.
memberBindingSource.DataSource = Person.CountyList();
lkuCounty.Properties.DataSource = memberBindingSource;
lkuCounty.Properties.PopulateColumns();
lkuCounty.Properties.DisplayMember = "CountyName";
lkuCounty.Properties.ValueMember = "CountyID";
lkuCounty.Properties.Columns[0].Visible = false;
lkuCounty.Properties.Columns[2].Visible = false;
lkuCounty.Properties.Columns[3].Visible = false;
Is there a benefit to using the BindingSource? Is there a negative to doing it the OTHER WAY?
For context, this is a WinForm CRUD app in C# using SQL 2005.