BindingSource And User Controls

BindingSource And User Controls

Old forum URL: forums.lhotka.net/forums/t/2290.aspx


JZuerlein posted on Tuesday, February 06, 2007

I have a situation where I'm trying to get some code reuse in my GUI, by using a custom user control.  As an example...I have two forms, one to display people and a second to display companies.  Both forms have a detail section to display addresses.  My idea was to create a custom control to display addresses, and add it to both the person form, and the company form. 

Both of the forms have a BindingSource object.  The address user control has a BindingSource as well. 

Me.ucAddresses.AddressesBindingSource.DataSource = Me.PersonBindingSource

My problem is that in the custom user control, I need to add an item to the Person.Addresses collection.  It won't let me, because there is no public constructor.  I was expecting it would use the AddNewCore() function, but that doesn't appear to be the case.

cur = Me.AddressesBindingSource.AddNew()

Does anyone have any suggestions on how I should deal with this problem?

 

xal replied on Wednesday, February 07, 2007

Well, how did you override AddNewCore() ? Can we see the code?
Did you set AllowNew = True for your collection?


Andrés

JZuerlein replied on Wednesday, February 07, 2007

My bad.

On the form I was testing, the line....

Me.ucAddresses.AddressesBindingSource.DataSource = Me.PersonBindingSource

was not getting executed.

Thanks,

Jeff

Copyright (c) Marimer LLC