473,655 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How Do I Pass Bindingsource to Another Winform.

Hi,

I have two c# Winforms. the first form has a datagridview who's datasource
is a
bindingsource. when you double click on a datagridview row it then opens my
second form, which has some databound controls, text boxes that are bound to
another bindingsource. Both bindingsources are bound to the same dataset,
and contain the same information. Within my second forms Load method I fill
my dataset that is bound to my bindingsource with the content of the current
record selected from my first form. but the problem is that when I save the
changes made within my second form and close it that these changes are not
reflected within my first forms datagridviews contents unless I Fill the
dataset again.

I'm assuming that what I need to do is use the bindingsource that is
contained within my first form in my second form, that way any changes will
be immediately reflected back into my main form.. If this is the case, how
do I go about doing this.?

Any suggestions would be greatly appreciated.

Thanks
May 5 '06 #1
5 7838
I first would like to say that I am a novice and I'm just throwing it
out there, but my belief is that you would have to pass a reference to
that binding source in your call to Load the second Form, that way any
changes made are being done to the first winform's binding source.
I'd actually like to know how to do this myself if this isn't the
best(or even close to right) way of getting the information to sync.

May 5 '06 #2
Hi,

Thats what I thought, but how do you assign the value of the bindsource
from winform1 to the new bindingsource on the winform2 side. In C++ I would
know how to do this but in c# I don't have a clue as it doesn't seem to make
use of pointers... and not sure how you would pass something by reference,
i.e @bindingsource

Any help would be appreciated...
May 5 '06 #3
By default, a class in C# is passed by ref, and a struct is passed by value.

Rob Dob wrote:
Hi,

Thats what I thought, but how do you assign the value of the bindsource
from winform1 to the new bindingsource on the winform2 side. In C++ I would
know how to do this but in c# I don't have a clue as it doesn't seem to make
use of pointers... and not sure how you would pass something by reference,
i.e @bindingsource

Any help would be appreciated...

May 7 '06 #4
sorry for the long pause b/w posts....

it would be along the lines of
Form form2 = new Form(ref BindingSource);

and then in form2's constructor it'd look like:

public form2(ref BindingSourceNa me)
{
..
..
enter code to manipulate BindingSourceNa me
..
..
}

you can set it to that other BindingSource in form2, for something
along the lines of

public form2(ref BindingSourceNa me)
{
..
BindingSource2 = BindingSourceNa me;
enter code to manipulate BindingSource2
..
..
}

and then your changes should be reflected, once again, I'm actually
playing with that kind of code myself, and I don't have the means right
now to test and see if that is even possible to pass a whole
bindingsource to another form

May 8 '06 #5
"Rob Dob" wrote:
I have two c# Winforms. the first form has a datagridview who's datasource
is a
bindingsource. when you double click on a datagridview row it then opens my
second form, which has some databound controls, text boxes that are bound to
another bindingsource. Both bindingsources are bound to the same dataset,
and contain the same information. Within my second forms Load method I fill
my dataset that is bound to my bindingsource with the content of the current
record selected from my first form. but the problem is that when I save the
changes made within my second form and close it that these changes are not
reflected within my first forms datagridviews contents unless I Fill the
dataset again.

I'm assuming that what I need to do is use the bindingsource that is
contained within my first form in my second form, that way any changes will
be immediately reflected back into my main form.. If this is the case, how
do I go about doing this.?

Any suggestions would be greatly appreciated.

Thanks


I am dealing with a similar issue. My suggestion is take a look at the
BindingSource.R esetBindings method at
http://msdn2.microsoft.com/en-us/lib...tbindings.aspx

Please post your ongoing experiences on this. I am sure between us we can
work something out.

Mark

May 17 '06 #6

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

Similar topics

0
1639
by: Michael Rodriguez | last post by:
I have a custom business object collection based on the CSLA.NET framework from Rockfor Lhotka's "Expert C# Business Objects" book. I bound my winform to the object and when I open the screen the records are there and I can scroll through them. The problem is when I call BindingSource.AddNew() it doesn't seem to work. I stepped through the code and a new object is being created, it just doesn't get added to the list. If I manually call...
4
1281
by: acool | last post by:
I want the ability to fill in the public properties of a given class in a webform pump that class into a session variable and then recreate a new instance of that class in order to grab those same properties. The only thing that has me stumped is how to grab the appropriate session object in order to grab th right class. Can this be done or is there a better way to do this?
3
3917
by: silesius | last post by:
Hi All, I have two pagetabs. One pagetab is used to display a parent record and the other is suppose to display 3 related child records from another table. I can display the parent records just fine by using the bindingSource and a tableAdapter to fill the dataset. I'm having a problem displaying the 3 related records on the other pagetab. I can only bind to one record and have the bindingsource populate one set of databound contorls. I...
2
6325
by: Bryan Shaw | last post by:
I have a Windows app I am developing in VS .NET 2005 that is required to periodically look at the data in a table in an MS SQL 2000 database. The data is being changed from an external stored procedure. All I want the app to do is refresh the data bound controls on a timer tick. I am using the new TableAdapter and BindingSource controls as recommended in the Help. I am at a loss as to the method to use to get the BindingSource to do...
4
16728
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part I: I found the ValueType field, leading me to believe that I could say dataGridView.Columns.ValueType = typeof(Double); dataGridView.Columns.ValueType = typeof(Integer); etc.
6
14973
by: BD | last post by:
Hi, I have a "Cancel" button on a form to cancel any changes in the current item with the code BindingSource1.CancelEdit but this don't restore the older's values that had been changed. The BindingSource.DataSource is a type of BindingList<MyClass>. What's I'm doing wrong? 's BD
1
1177
by: Frank Rizzo | last post by:
Hello, I've taken over a .net 2.0 project that makes heavy use of Data Binding of business classes to 3rd party WinForm controls via the BindingSource class and INotifyPropertyChanged interface. The setup in generally works ok, but the app feels sluggish. Because BindingSource is basically a black box, I am having trouble determining where the sluggishness comes from: BindingSource or 3rd party controls. or a combination thereof. Any...
5
4931
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This will make it clear to the user that they have to create a new item first before they start working. This needs to be an easy process because there are many, many forms.
0
2240
Sepidar
by: Sepidar | last post by:
hi, I have a DataGridView on my winform linked to a BindingSource linked to a Linq to SQL class. My problem is when I update my underlying class, the BindingSource will not notified and my DataGridView will not update. What should I do to resolve this problem?
0
8380
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
8816
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...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7310
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
6162
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
5627
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
4150
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...
1
2721
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
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.