Multiple Forms bound to same BindingSource

C

cppquester

I got a forms library build from a data source with the designer.
I want to use that as a custom widget (sevral instances).
The designer included BindingSources for the controls in my forms
library.

Is there a way to use only one set of BindingSources for several
instances
of the forms?
Other than excluding all the designer generated code concerning the
BindingSource objects and redo it by hand using e.g. static memebers
for the
BindingSource instead.
Is there a way the desinger supports this?

Thanks,
Marc
 
M

Marc Gravell

Is there a way the desinger supports this?

The short answer is "no".
using e.g. static memebers for the
BindingSource instead.

Don't go near statics for this; perhaps have an instance property
("public BindingSource DataSource {get;set;}") or method ["public
Bind(BindingSource source)"] would allow you to do this per instance,
but you'd need to wire it up so that after you have created your child-
controls you pass the binding-source over.
You might be able to cut/paste the binding code from the designer.cs
into a private method that sits behind the above; to be honest, I
would do this last step regardless, simply because the designer has a
distressing habit of losing bindings whenever it has a panic. If they
are in *your* code it is harder for the IDE to mess it up. But it
means you don't get quite as pretty a design-time experience (but
then: I care more for what happens at execution that what it looks
like in the IDE).

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top