Solved

Bind to dataset on main form from second form.

Posted on 2006-11-22
12
206 Views
Last Modified: 2010-04-23
Not sure if I am doing something wrong here but I can bind to the dataset on my main form perfectly and the data shows in my controls. The problem is the data in the second form is not advancing ?? The data in the main form is advancing and both controls are bound exactly the same, with no changes. Why would one advanced and the others not ?

0
Comment
Question by:ParanoidOne
  • 6
  • 4
  • 2
12 Comments
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 17996875
Please explain your current implementation scenario. Is both forms having same coding with independent Dataset? Or DataSet is placed in Form1 and Accessing from Form2 ? If so, How you passed Dataset to second form? ByRef or ByVal? Please Explain

Thanks.
0
 

Author Comment

by:ParanoidOne
ID: 17996924
The dataset is on the main form (form1). This is the form load for Form 2.

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim b As Binding
        Dim i(7, 2) As Object

        i(0, 0) = txtLast
        i(1, 0) = txtFirst
        i(2, 0) = txtMiddle
        i(3, 0) = txtEmail
        i(4, 0) = txtAddress
        i(5, 0) = txtCity
        i(6, 0) = txtState
        i(7, 0) = txtZip

        i(0, 1) = MyForm1.SQLCase
        i(1, 1) = MyForm1.SQLCase
        i(2, 1) = MyForm1.SQLCase
        i(3, 1) = MyForm1.SQLCase
        i(4, 1) = MyForm1.SQLCase
        i(5, 1) = MyForm1.SQLCase
        i(6, 1) = MyForm1.SQLCase
        i(7, 1) = MyForm1.SQLCase


        i(0, 2) = "icase.icaseparty.last"
        i(1, 2) = "icase.icaseparty.first"
        i(2, 2) = "icase.icaseparty.middle"
        i(3, 2) = "icase.icaseparty.email"
        i(4, 2) = "icase.icaseparty.address"
        i(5, 2) = "icase.icaseparty.city"
        i(6, 2) = "icase.icaseparty.state"
        i(7, 2) = "icase.icaseparty.zip"

        Dim l As Integer
        For l = 0 To i.GetUpperBound(0)
            b = New Binding("Text", i(l, 1), i(l, 2))
            Try
                i(l, 0).DataBindings.Add(b)
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
        Next
    End Sub
0
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 17997116
from where you are adding records to dataset?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ParanoidOne
ID: 17997155
You mean filling the dataset ? The dataset is filled in form1. Records are not being added anywhere, they are already there in the database.
0
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 17997234
Did you say, MyForm1.SQLCase is having data but not getting bound to your controls? Or you aint getting any data at runtime on even dataset?
0
 

Author Comment

by:ParanoidOne
ID: 17997290
Myform1 is working beautiful. When I advance the BM the textbox on form1 shows the data perfectly. The textbox on Form2 shows the first record no matter what. Both forms are bound Exactly the same way to the same dataset and same datamember. The only difference in the two is the MyForm1.SQLCase reference instead of SQLCase
0
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
ID: 17997330
The two forms will have different bindingcontexts, hence binding managers.  You need to reed the Remarks in this link

http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingcontext.aspx

When "The data in the main form is advancing" that is because the binding manager for that data, on that form, is changing .Position.  But because the "the data in the second form" has a different binding manager, for which the .Position is not changing, it "is not advancing".  It may be possible to synchronise them, but we would need to know a bit more about the overall set up.  E.g. why are you showing the same data on two forms?  Is one form a child of the other?  That sort of thing.

Roger
0
 

Author Comment

by:ParanoidOne
ID: 17997342
Well the first form just shows the customers name, the second form will be to edit the data like the address and such. Any ideas on a different way, I am open to suggestion.
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17997407
A Panel or GroupBox on the first form - containing the detail fields from the second form - that you make visible or not (and possibly resize the form to accommodate) depending on whether you are in edit mode or not?

Roger
0
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 17997435
A tabcontrol isnt enough to manage in a single form?
0
 

Author Comment

by:ParanoidOne
ID: 17997524
Yeah I can do that, the second form just look cool !!
0
 

Author Comment

by:ParanoidOne
ID: 17997778
Better yet I did this and like it better.

Me.BindingContext(MyForm1.SQLCase, "icase").Position = MyForm1.BindingContext(MyForm1.SQLCase, "icase").Position
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with consolidating excel files using VB.net 2 35
VB.Net Determine if a mapped network drive exists 2 52
Vb.net threads keep increasing 2 48
Need help with a query 14 33
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question