Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / May 2006

Tip: Looking for answers? Try searching our database.

How Do I Pass Bindingsource to Another Winform.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Dob - 05 May 2006 21:21 GMT
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
GTeachey@gmail.com - 05 May 2006 21:32 GMT
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.
Rob Dob - 05 May 2006 22:47 GMT
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...
GTeachey@gmail.com - 08 May 2006 02:34 GMT
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
SparkPlug - 17 May 2006 16:44 GMT
> I have two c# Winforms.  the first form has a datagridview who's datasource
> is a
[quoted text clipped - 16 lines]
>
> 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/library/system.windows.forms.bindingsource.rese
tbindings.aspx


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

Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.