PC Review


Reply
Thread Tools Rate Thread

DtaGridView - Add DataBinding using bindingsource

 
 
Ryan
Guest
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

i.e.

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
work:
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!
Ryan
 
Reply With Quote
 
 
 
 
Ryan
Guest
Posts: n/a
 
      15th May 2008
Hi RobinS!

That makes sense, thanks for your help!

Ryan
 
Reply With Quote
 
 
 
Reply

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


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:01 PM.