PC Review

Thread Tools Rate Thread

DtaGridView - Add DataBinding using bindingsource

Posts: n/a
      14th May 2008
Hello all,

I am relatively new to windows forms and I am trying to make this work
(pseudo code):

Create bindingsource.
Set DataSource property of bindingsource to generic list
Check to see if datasource of datagridview is null
if it isn't add databindings


private BindingSource bs = new BindingSource();
bs.DataSource = objList.CollBuildings;

if (dgvBuildings.DataBindings["DataSource"] == null)
dgvBuildings.DataBindings.Add(new Binding("DataSource", bs, ""));
} // end if

It doesn't error, but I get no data displayed in the grid. This does
dgvBuildings.DataSource = bs;

Is there some advantage to using the DataBindings.Add as opposed to
setting the datasource directly?

Thanks for your help and have a great day!
Reply With Quote
Posts: n/a
      15th May 2008
Hi RobinS!

That makes sense, thanks for your help!

Reply With Quote

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
databinding combobox to a bindingsource - value of '0' is not valid for 'selectedindex' BillE Microsoft VB .NET 0 24th Aug 2009 06:40 PM
EDM databinding using BindingSource? Edward Microsoft ADO .NET 1 25th Sep 2008 04:41 PM
C# 2.0 DataBinding using the BindingSource in user controls Rajat Microsoft Dot NET Framework Forms 0 27th Oct 2006 03:46 PM
Databinding and Bindingsource issue Newish Microsoft Dot NET Framework Forms 0 15th Oct 2006 02:04 PM
Databinding: "BindingSource - field" syntax Marc Vangrieken Microsoft Dot NET Framework Forms 2 11th Aug 2006 10:43 AM




All times are GMT +1. The time now is 01:30 AM.