How Do I Pass Bindingsource to Another Winform.

Discussion in 'ASP .Net Datagrid Control' started by Rob Dob, May 5, 2006.

  1. Rob Dob

    Rob Dob Guest

    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
    Rob Dob, May 5, 2006
    #1
    1. Advertising

  2. Rob Dob

    Guest

    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, 2006
    #2
    1. Advertising

  3. Rob Dob

    Rob Dob Guest

    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...
    Rob Dob, May 5, 2006
    #3
  4. Rob Dob

    Guest

    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, 2006
    #4
  5. Rob Dob

    SparkPlug Guest

    "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/library/system.windows.forms.bindingsource.resetbindings.aspx

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

    Mark
    SparkPlug, May 17, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. acool
    Replies:
    4
    Views:
    537
    Mark Travis
    May 27, 2004
  2. =?Utf-8?B?RFdyZWs=?=

    HTTPWebResponse: Winform = Pass; ASP DLL = Fail

    =?Utf-8?B?RFdyZWs=?=, Nov 30, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,881
    Steven Cheng[MSFT]
    Dec 3, 2004
  3. Rob Dob

    BindingSource, Archiving Old record before saving new changes

    Rob Dob, Mar 14, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    129
    Brian Smith
    Mar 16, 2006
  4. Rob Dob

    How Do I Pass Bindingsource to Another form.

    Rob Dob, May 5, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    167
    David Thielen
    May 6, 2006
  5. Rob Dob

    How Do I Pass Bindingsource to Another form.

    Rob Dob, May 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    175
    David Thielen
    May 6, 2006
Loading...

Share This Page