473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to Use the Same BindingSource Across Multiple UserControls

Hello:

I'm working on improving some of our Windows Forms.

I have created two user controls that I want to bind to the same
BindingSource.

I have an overview control that is used just to identify a customer.
Then there is a details view that shows all their specifics. I wanted
to keep navigation outside of my view. There is also a
BindingNavigator that I want to hook up to the same BindingSource.
When I navigate, I want the two user controls to keep in-sync.

The problem is that I have a BindingSource in each control and I bind
all the child controls to it. So, when I try to change the
BindingSource, it appears as though nothing happens. This is because
the child controls are hard-set to point at the original
BindingSource.

Is there a way to change which BindingSource the child controls are
looking at?

Tell me if I'm being unclear.

Thanks,
Travis
Sep 19 '08 #1
2 4479
I found a working solution to this problem. I created a class called
IndirectBindingSource. It inherits from and implements all the classes
and interfaces of BindingSource. I implement all of the methods by
redirecting them to the methods inside a BindingSource that I pass via
a property.

The designer just thinks I have another BindingSource. In my user
controls, I still have a BindingSource that points to the data. I set
my IndirectBindingSource's BindingSource to that BindingSource. The
BindingSource picks up all the type properties. My
IndirectBindingSource picks up all of those properties too. I just
bind my user controls to the IndirectBindingSource.

My user controls provide a property called BindingSource that will get
and set the BindingSource inside the IndirectBindingSource. Since
these properties are visible to the Designer, I can set all my
BindingSources at design time.

At run time, I just set the DataSource of the BindingSource in my main
form. Since every control uses the same BindingSource, directly or
indirectly, everything works out smoothly.

It is pretty cool, if not a little hackish. The code is pretty simple
too. Outside of the user controls, no one has any clue I am being
sneaky.
Sep 19 '08 #2
I have to say this is a most confusing description of a problem.

If you want the binding source to follow everything then ALL controls
should bind to it. When you want to split you then have to create a
second binding source. For example, I have two players from one team on
the field at any one time, I have a tab with two binding sources one for
each player and they work independently. If I use one binding source for
all then changing details on one player will change the second to that
player automatically.

I had problems changing position on a binding source this was related to
null datetime elements, the datetime controls reject the update and the
binding source moves you back.
Sep 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: byrocat | last post by:
We have a requirement to run a query on all of the DB2 databses on a regular basis. Obviously, doing this manually is going to be a waste of several people's time. The ideal solution would be...
1
by: ngodugu | last post by:
Hi All, Is there any way to use a common login page across multiple web applications? I have tried couple of things that were suggested on MSDN but they did not work. ...
2
by: Jim Tilson | last post by:
I'm having a problem with Session ID being duplicated across multiple IE windows. I edited the web.config for my ASP.net web application to display trace information on the page. I open an IE...
2
by: Brian Henry | last post by:
is there any way to make an assembly file accessable across multiple projects (we have over 20 that need the info all to be the same at build version, title, desc, copyright,etc) i saw MS did this...
1
by: Punisher | last post by:
Is this possible? We have 7 webservers servering up the same content, but each has a different viewstate. How can we make them all have the same one?
1
by: Felipe Roucher | last post by:
Hello, I 've a Windows Form and a "DataGridView" with the "DataSource" binding with a "BindingSource" and a "BindingNavigator", in the other hand in the same Form, there's multiples textbox's...
4
by: Mike | last post by:
Class A public objX I want to create 2 or more instances of Class A and have the same value for objX in all instances. Instance1 of Class A Instance2 of Class A Instance3 of Class A
13
by: Samir Chouaieb | last post by:
Hello, I am trying to find a solution to a login mechanism for different domains on different servers with PHP5. I have one main domain with the user data and several other domains that need...
2
by: Mas Heru | last post by:
I heard the best method to share session across multiple domains on same server is to use custom php session handler. (ie, domain name different like abc.com, xyz.com but single application.) But...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.