473,396 Members | 2,010 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,396 software developers and data experts.

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 7815
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 BindingSourceName)
{
..
..
enter code to manipulate BindingSourceName
..
..
}

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

public form2(ref BindingSourceName)
{
..
BindingSource2 = BindingSourceName;
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.ResetBindings 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
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...
4
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...
3
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...
2
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...
4
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...
6
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...
1
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. ...
5
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...
0
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...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.