|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Binding currencyManager and dataRelation - datagridview - possibleFollowing an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows in datagridview2 that corresponded to a selected row in datagridview1. Great article/example. Now I am navigating through the primary table using currencyManager and displaying the data in textboxes rather than a datagridview. But I am still using a datagridview for the secondary table. I bind the currencymanager to the primary table, and I have a datarelation between the primary table and the secondary table. But when I move to another row in the primary table using the currencymanager, the datagridview is not displaying the corresponding rows in the secondary table. Is there a way I can navigate the primary table using currency manager and display the corresponding rows of the secondary table in the datagridview using the datarelation? I was previously using a dataview and the dataview.Rowfilter for synchronizing the datagridview rows with the current row in the primary table. This technique worked, but I believe the datarelation method is better. Here is the code I am using for the datarelation and currencty manager technique: Priavate Sub Form1_Load(...) .... Dim daPrimary As New SqlClient.SqlDataAdapter("Select * From PrimaryTbl", conn) Dim daSecondary As New SqlClient.SqlDataAdapter("Select * From SecondaryTbl", conn) daPrimary.Fill(ds, "Prinmary") daSecondary.Fill(ds, "Secondary") ds.Relations.Add("relPrimarySecondary", ds.Tables("Primary").Columns("ID"), ds.Tables("Secondary").Columns("SubID")) DataGridView1.DataSource = ds DataGridView1.DataMember = "Primary.relPrimarySecondary" curMgr = CType(Me.BindingContext(ds.Tables("Primary")), CurrencyManager) curMgr.Position = 0 Me.txt0.DataBindings.Add("Text", ds.Tables("Primary"), "ID") Me.txt1.DataBindings.Add("Text", ds.Tables("Primary"), "fName") Me.txt2.DataBindings.Add("Text", ds.Tables("Primary"), "lName") End Sub Private Sub btn1_Click(...) curMgr.Position += 1 End Sub The currencymanager will iterate through the primary table. Is it possible to synchronize the datagridview with the primary table using a datarelation? How to do this? Thanks, Rich I came up with one solution for using currencyManager and synchronizing rows
from primary table to datagridview2, but it is not ideal because it involves binding currencymanager to datagridview1, so my textboxes do not display the current data.. The goal is to be able to iterate through Primary table and display that data in the textboxes and the corresponding rows in datagridview2. I also tried some code that will bind the currencyManager to the dataRelation, but does not iterate through the Primary table. Here is what I have so far which uses the currencyManager bound to datagridview1: ______________________________________________ .... curMgr = CType(Me.DataGridView1.BindingContext(ds, "Primary"), CurrencyManager) DataGridView1.DataSource = ds DataGridView2.DataSource = ds DataGridView1.DataMember = "Primary" DataGridView2.DataMember = "Primary.relPrimarySecondary" End Sub Sub curMrgInc() curMgr.Position =+ 1 End Sub ----------------------------------------------------- Here is the binding of currencyManager to the datarelation: curMgr = CType(Me.BindingContext(ds, "Primary.relPrimarySecondary"), CurrencyManager) But this does not iterate anything. My alternative would be to have 2 currencyManagers - One for the datagridviews and one for the textboxes. The goal is to be able to iterate through Primary Table - display the current row in the textboxes and display the corresponding rows from Secondary Table in the datagridview - using only one currencyManager. The only way I have been able to do this so far is by using Dataview.Rowfilter. How can I bind currencyManager to Primary Table and have Secondary Table synchronized with Primary? Show quoteHide quote "Rich" wrote: > Hello, > > Following an example at > > http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) > > on binding a dataRelation to a Datagridview for sqlClient, I was able to > view rows in datagridview2 that corresponded to a selected row in > datagridview1. Great article/example. > > Now I am navigating through the primary table using currencyManager and > displaying the data in textboxes rather than a datagridview. But I am still > using a datagridview for the secondary table. I bind the currencymanager to > the primary table, and I have a datarelation between the primary table and > the secondary table. But when I move to another row in the primary table > using the currencymanager, the datagridview is not displaying the > corresponding rows in the secondary table. > > Is there a way I can navigate the primary table using currency manager and > display the corresponding rows of the secondary table in the datagridview > using the datarelation? I was previously using a dataview and the > dataview.Rowfilter for synchronizing the datagridview rows with the current > row in the primary table. This technique worked, but I believe the > datarelation method is better. Here is the code I am using for the > datarelation and currencty manager technique: > > Priavate Sub Form1_Load(...) > ... > Dim daPrimary As New SqlClient.SqlDataAdapter("Select * From PrimaryTbl", > conn) > Dim daSecondary As New SqlClient.SqlDataAdapter("Select * From > SecondaryTbl", conn) > > daPrimary.Fill(ds, "Prinmary") > daSecondary.Fill(ds, "Secondary") > > ds.Relations.Add("relPrimarySecondary", ds.Tables("Primary").Columns("ID"), > ds.Tables("Secondary").Columns("SubID")) > DataGridView1.DataSource = ds > DataGridView1.DataMember = "Primary.relPrimarySecondary" > > curMgr = CType(Me.BindingContext(ds.Tables("Primary")), CurrencyManager) > curMgr.Position = 0 > > Me.txt0.DataBindings.Add("Text", ds.Tables("Primary"), "ID") > Me.txt1.DataBindings.Add("Text", ds.Tables("Primary"), "fName") > Me.txt2.DataBindings.Add("Text", ds.Tables("Primary"), "lName") > End Sub > > Private Sub btn1_Click(...) > curMgr.Position += 1 > End Sub > > The currencymanager will iterate through the primary table. Is it possible > to synchronize the datagridview with the primary table using a datarelation? > How to do this? > > Thanks, > Rich > Rich,
I did not investigate your latest problem, but I am afraid I did this already to often. I have the idea that you are now at the limitations of the relations about which I was speaking in the first messages of the problem. At least I cannot reach the currency manager with the relations. Therefore we have as well that sample of faking a datarelation on our website using the dataview. Does not helps you, but maybe it helps, that you are not the only one with this problem. Cor Show quoteHide quote "Rich" <R***@discussions.microsoft.com> schreef in bericht news:99D4676E-CC7D-4D3B-AFEA-382422B0136B@microsoft.com... >I came up with one solution for using currencyManager and synchronizing >rows > from primary table to datagridview2, but it is not ideal because it > involves > binding currencymanager to datagridview1, so my textboxes do not display > the > current data.. The goal is to be able to iterate through Primary table > and > display that data in the textboxes and the corresponding rows in > datagridview2. I also tried some code that will bind the currencyManager > to > the dataRelation, but does not iterate through the Primary table. Here is > what I have so far which uses the currencyManager bound to datagridview1: > ______________________________________________ > ... > curMgr = CType(Me.DataGridView1.BindingContext(ds, "Primary"), > CurrencyManager) > DataGridView1.DataSource = ds > DataGridView2.DataSource = ds > > DataGridView1.DataMember = "Primary" > DataGridView2.DataMember = "Primary.relPrimarySecondary" > End Sub > > Sub curMrgInc() > curMgr.Position =+ 1 > End Sub > ----------------------------------------------------- > Here is the binding of currencyManager to the datarelation: > > curMgr = CType(Me.BindingContext(ds, "Primary.relPrimarySecondary"), > CurrencyManager) > > But this does not iterate anything. My alternative would be to have 2 > currencyManagers - One for the datagridviews and one for the textboxes. > The > goal is to be able to iterate through Primary Table - display the current > row > in the textboxes and display the corresponding rows from Secondary Table > in > the datagridview - using only one currencyManager. The only way I have > been > able to do this so far is by using Dataview.Rowfilter. How can I bind > currencyManager to Primary Table and have Secondary Table synchronized > with > Primary? > > > "Rich" wrote: > >> Hello, >> >> Following an example at >> >> http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken >> Tucker) >> >> on binding a dataRelation to a Datagridview for sqlClient, I was able to >> view rows in datagridview2 that corresponded to a selected row in >> datagridview1. Great article/example. >> >> Now I am navigating through the primary table using currencyManager and >> displaying the data in textboxes rather than a datagridview. But I am >> still >> using a datagridview for the secondary table. I bind the currencymanager >> to >> the primary table, and I have a datarelation between the primary table >> and >> the secondary table. But when I move to another row in the primary table >> using the currencymanager, the datagridview is not displaying the >> corresponding rows in the secondary table. >> >> Is there a way I can navigate the primary table using currency manager >> and >> display the corresponding rows of the secondary table in the datagridview >> using the datarelation? I was previously using a dataview and the >> dataview.Rowfilter for synchronizing the datagridview rows with the >> current >> row in the primary table. This technique worked, but I believe the >> datarelation method is better. Here is the code I am using for the >> datarelation and currencty manager technique: >> >> Priavate Sub Form1_Load(...) >> ... >> Dim daPrimary As New SqlClient.SqlDataAdapter("Select * From PrimaryTbl", >> conn) >> Dim daSecondary As New SqlClient.SqlDataAdapter("Select * From >> SecondaryTbl", conn) >> >> daPrimary.Fill(ds, "Prinmary") >> daSecondary.Fill(ds, "Secondary") >> >> ds.Relations.Add("relPrimarySecondary", >> ds.Tables("Primary").Columns("ID"), >> ds.Tables("Secondary").Columns("SubID")) >> DataGridView1.DataSource = ds >> DataGridView1.DataMember = "Primary.relPrimarySecondary" >> >> curMgr = CType(Me.BindingContext(ds.Tables("Primary")), CurrencyManager) >> curMgr.Position = 0 >> >> Me.txt0.DataBindings.Add("Text", ds.Tables("Primary"), "ID") >> Me.txt1.DataBindings.Add("Text", ds.Tables("Primary"), "fName") >> Me.txt2.DataBindings.Add("Text", ds.Tables("Primary"), "lName") >> End Sub >> >> Private Sub btn1_Click(...) >> curMgr.Position += 1 >> End Sub >> >> The currencymanager will iterate through the primary table. Is it >> possible >> to synchronize the datagridview with the primary table using a >> datarelation? >> How to do this? >> >> Thanks, >> Rich >>
scope of command and garbage collection
How to Use a Screen Saver app within My Application? Object from variable Question about a conversion project Need help with Conversion from C# to VB.net SET ARITHABORT ON: Why (not)? Web Service Off Topic - sorry Inline SQL vs stored procs on SQL Server 7 and 2000 Alternate Name |
|||||||||||||||||||||||