473,785 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
BindingNavigato r 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 4508
I found a working solution to this problem. I created a class called
IndirectBinding Source. 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 IndirectBinding Source's BindingSource to that BindingSource. The
BindingSource picks up all the type properties. My
IndirectBinding Source picks up all of those properties too. I just
bind my user controls to the IndirectBinding Source.

My user controls provide a property called BindingSource that will get
and set the BindingSource inside the IndirectBinding Source. 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
1800
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 to run a process from a workstation. If this was a Sybase database, we could use ISQL in command mode, using a command string like
1
2539
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. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformsauthenticationacrossapplications.asp This technique falters when the second web application is looking for a
2
8005
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 window and navigate to the home page of my ASP.net app, and note the Session ID that was assigned. I then type CTRL-N to open a new IE window. The session ID displayed on the
2
2791
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 with the quick starts with what looks like to be a short cut to a file in each project... is there any way to have the assembly as the actuall file in one project and all the others reference it? this is also a source controled solution too by the...
1
1491
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
3445
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 binding with the same "BindingSource". Well, only I want to know if there's any automatic way to change the values of all selected rows in a datagridview, when I change the TextBox's text. Thank you.
4
3148
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
8676
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 a login to show data. I want the user to login only once when he visits any of my domains.
2
4347
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 after i tried it, even custom php session handler that using SAME DATABASE ON 1 SERVER can't share session, when i tried to read cookie value from different domain. Here's my custom session handler, Please kindly check or fix if something missing...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.