PC Review


Reply
Thread Tools Rate Thread

BindingSource, Custom DataSource and DataGridView driving me mad!

 
 
Steve
Guest
Posts: n/a
 
      20th Jun 2006
Hi-

OK, I've got a DataGridView, I've created a BindingSource from one of my
Business Entity object (based on generated classes from EntitySpaces) I've
left the default column setup so that all the columns are displayed.

My DataSource objects are composed like this:

class Customer : esCustomer // where esCustomer is the EntitySpaces class
that was generated
{
public string PropTest
{
get{ return "PropTest!"; }
}
}


esCustomer has some properties as well that were generated from my DB
schema, but from what I can see from teh code.. that shouldn't matter.

The problem is, all the properties that are in esCustomer are bound to the
DataGridView correctly, however none of the properties I add to Customer are
displayed.
I have checked and double checked that I'm indeed using the correct class
for the BindingSource object.

I've searched for events that I can subscribe to so I can try and debug the
binding process, but I'm not seeing anything that appears to expose the code
that is trying to fetch the properties.

I'm stuck and frustrated. Anyone want to suggest anything I should try?

Thanks for reading,
Steve Klett


 
Reply With Quote
 
 
 
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      20th Jun 2006
Steve,

Did you actually write a code to bind the binding source to an instance of
your Customer class. This is not done by the designer. The designer uses the
class to initialize the datagirdview, but doesn generate code to bind the
binding source to actuall instance of that class. It can do that because it
doesn't know where to get this instance from.

If you look at the InitializeComponent method you'll see that the binding
source is actually set up with the Type object of your class. This doesn do
much at run time.

What you need to do is in your form constructor or in some other place in
your code after the InitialzeComponent is called you need to add

this.customerBindingSource.DataSource = this.costumer;

where this.contumer is created and instialized instance of the Costumer
class.

BTW if you want the datagridview to reflect the changes made to the
properties of the business at run-time (after the grid is bound) your
business object needs to implement INotifyPropertyChanged interface and fire
the event anytime a property changes

--
HTH
Stoitcho Goutsev (100)

"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi-
>
> OK, I've got a DataGridView, I've created a BindingSource from one of my
> Business Entity object (based on generated classes from EntitySpaces) I've
> left the default column setup so that all the columns are displayed.
>
> My DataSource objects are composed like this:
>
> class Customer : esCustomer // where esCustomer is the EntitySpaces
> class that was generated
> {
> public string PropTest
> {
> get{ return "PropTest!"; }
> }
> }
>
>
> esCustomer has some properties as well that were generated from my DB
> schema, but from what I can see from teh code.. that shouldn't matter.
>
> The problem is, all the properties that are in esCustomer are bound to the
> DataGridView correctly, however none of the properties I add to Customer
> are displayed.
> I have checked and double checked that I'm indeed using the correct class
> for the BindingSource object.
>
> I've searched for events that I can subscribe to so I can try and debug
> the binding process, but I'm not seeing anything that appears to expose
> the code that is trying to fetch the properties.
>
> I'm stuck and frustrated. Anyone want to suggest anything I should try?
>
> Thanks for reading,
> Steve Klett
>



 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      21st Jun 2006
Very good information, thank you for taking the time to explain this! I'm
up and running now.
Have a good day,
Steve

"Stoitcho Goutsev (100)" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Steve,
>
> Did you actually write a code to bind the binding source to an instance of
> your Customer class. This is not done by the designer. The designer uses
> the class to initialize the datagirdview, but doesn generate code to bind
> the binding source to actuall instance of that class. It can do that
> because it doesn't know where to get this instance from.
>
> If you look at the InitializeComponent method you'll see that the binding
> source is actually set up with the Type object of your class. This doesn
> do much at run time.
>
> What you need to do is in your form constructor or in some other place in
> your code after the InitialzeComponent is called you need to add
>
> this.customerBindingSource.DataSource = this.costumer;
>
> where this.contumer is created and instialized instance of the Costumer
> class.
>
> BTW if you want the datagridview to reflect the changes made to the
> properties of the business at run-time (after the grid is bound) your
> business object needs to implement INotifyPropertyChanged interface and
> fire the event anytime a property changes
>
> --
> HTH
> Stoitcho Goutsev (100)
>
> "Steve" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi-
>>
>> OK, I've got a DataGridView, I've created a BindingSource from one of my
>> Business Entity object (based on generated classes from EntitySpaces)
>> I've left the default column setup so that all the columns are displayed.
>>
>> My DataSource objects are composed like this:
>>
>> class Customer : esCustomer // where esCustomer is the EntitySpaces
>> class that was generated
>> {
>> public string PropTest
>> {
>> get{ return "PropTest!"; }
>> }
>> }
>>
>>
>> esCustomer has some properties as well that were generated from my DB
>> schema, but from what I can see from teh code.. that shouldn't matter.
>>
>> The problem is, all the properties that are in esCustomer are bound to
>> the DataGridView correctly, however none of the properties I add to
>> Customer are displayed.
>> I have checked and double checked that I'm indeed using the correct class
>> for the BindingSource object.
>>
>> I've searched for events that I can subscribe to so I can try and debug
>> the binding process, but I'm not seeing anything that appears to expose
>> the code that is trying to fetch the properties.
>>
>> I'm stuck and frustrated. Anyone want to suggest anything I should try?
>>
>> Thanks for reading,
>> Steve Klett
>>

>
>



 
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
Datatable as bindingsource datasource John Microsoft ADO .NET 1 3rd Feb 2009 12:22 PM
BindingSource vs DataSource Bresco Microsoft Dot NET Framework Forms 1 26th Jan 2009 08:25 AM
Using ComboBox in DataGridView with custom classes as datasource Jan Obrestad Microsoft Dot NET Framework Forms 0 28th Sep 2007 08:03 AM
DataGridView, BindingSource and Custom object VueMme Microsoft ADO .NET 0 10th Aug 2007 02:08 PM
BindingSource.DataSource - Do I need InvokeRequired? Spam Catcher Microsoft VB .NET 0 29th Jan 2007 09:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 AM.