473,729 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding currencyManager and dataRelation - datagridview - possible

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.Rowfil ter 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.SqlDa taAdapter("Sele ct * From PrimaryTbl",
conn)
Dim daSecondary As New SqlClient.SqlDa taAdapter("Sele ct * From
SecondaryTbl", conn)

daPrimary.Fill( ds, "Prinmary")
daSecondary.Fil l(ds, "Secondary" )

ds.Relations.Ad d("relPrimarySe condary", ds.Tables("Prim ary").Columns(" ID"),
ds.Tables("Seco ndary").Columns ("SubID"))
DataGridView1.D ataSource = ds
DataGridView1.D ataMember = "Primary.relPri marySecondary"

curMgr = CType(Me.Bindin gContext(ds.Tab les("Primary")) , CurrencyManager )
curMgr.Position = 0

Me.txt0.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "ID")
Me.txt1.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "fName")
Me.txt2.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "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

May 24 '06 #1
2 11478
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.DataGr idView1.Binding Context(ds, "Primary"),
CurrencyManager )
DataGridView1.D ataSource = ds
DataGridView2.D ataSource = ds

DataGridView1.D ataMember = "Primary"
DataGridView2.D ataMember = "Primary.relPri marySecondary"
End Sub

Sub curMrgInc()
curMgr.Position =+ 1
End Sub
-----------------------------------------------------
Here is the binding of currencyManager to the datarelation:

curMgr = CType(Me.Bindin gContext(ds, "Primary.relPri marySecondary") ,
CurrencyManager )

But this does not iterate anything. My alternative would be to have 2
currencyManager s - 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.Rowfil ter. 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.Rowfil ter 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.SqlDa taAdapter("Sele ct * From PrimaryTbl",
conn)
Dim daSecondary As New SqlClient.SqlDa taAdapter("Sele ct * From
SecondaryTbl", conn)

daPrimary.Fill( ds, "Prinmary")
daSecondary.Fil l(ds, "Secondary" )

ds.Relations.Ad d("relPrimarySe condary", ds.Tables("Prim ary").Columns(" ID"),
ds.Tables("Seco ndary").Columns ("SubID"))
DataGridView1.D ataSource = ds
DataGridView1.D ataMember = "Primary.relPri marySecondary"

curMgr = CType(Me.Bindin gContext(ds.Tab les("Primary")) , CurrencyManager )
curMgr.Position = 0

Me.txt0.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "ID")
Me.txt1.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "fName")
Me.txt2.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "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

May 24 '06 #2
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

"Rich" <Ri**@discussio ns.microsoft.co m> schreef in bericht
news:99******** *************** ***********@mic rosoft.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.DataGr idView1.Binding Context(ds, "Primary"),
CurrencyManager )
DataGridView1.D ataSource = ds
DataGridView2.D ataSource = ds

DataGridView1.D ataMember = "Primary"
DataGridView2.D ataMember = "Primary.relPri marySecondary"
End Sub

Sub curMrgInc()
curMgr.Position =+ 1
End Sub
-----------------------------------------------------
Here is the binding of currencyManager to the datarelation:

curMgr = CType(Me.Bindin gContext(ds, "Primary.relPri marySecondary") ,
CurrencyManager )

But this does not iterate anything. My alternative would be to have 2
currencyManager s - 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.Rowfil ter. 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.Rowfil ter 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.SqlDa taAdapter("Sele ct * From PrimaryTbl",
conn)
Dim daSecondary As New SqlClient.SqlDa taAdapter("Sele ct * From
SecondaryTbl", conn)

daPrimary.Fill( ds, "Prinmary")
daSecondary.Fil l(ds, "Secondary" )

ds.Relations.Ad d("relPrimarySe condary",
ds.Tables("Prim ary").Columns(" ID"),
ds.Tables("Seco ndary").Columns ("SubID"))
DataGridView1.D ataSource = ds
DataGridView1.D ataMember = "Primary.relPri marySecondary"

curMgr = CType(Me.Bindin gContext(ds.Tab les("Primary")) , CurrencyManager )
curMgr.Position = 0

Me.txt0.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "ID")
Me.txt1.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "fName")
Me.txt2.DataBin dings.Add("Text ", ds.Tables("Prim ary"), "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

May 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1992
by: VMI | last post by:
I'm using Binding Manager to retrieve the current table row that the user clicked on (one highlighted row). But if I want to retrieve all the highlighted rows, how can I do it? This is the code to retrieve one row: DataRowView rowViewAudit = (DataRowView) ((CurrencyManager)BindingContext).Current; Now I want to modify this line so it retrieves all the highlighted rows. Is it possible?
10
1878
by: D | last post by:
hi I have a form with 2 datagrids showing related table data in a master / child or order / order details type relationship. I would like to auto select the row in the order details table which contains the highest priced item. My thoughts were to get the currency manager from the orderdetails table and iterate thru each row and keep track of the highest item and row and select that when done. I have found that for some reason the...
8
3926
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some addition fields. I'm able to get the datagrid to be properly populate with only the child records relating to the specified parent by setting the ..DefaultView.RowFilter property. Currently, to properly add a new child record, I need to manually...
2
3262
by: Rich | last post by:
Hello, I have a datagrid (dgr1) on a form and I'm trying to bind a currencyManager Object (cma) to it and print the current row position. But all I get for cma.Position is 0, 0, 0 for any row in dgr1. dgr1 populates correctly and when I first set cma - it shows the correct number of rows in the table (tbl1). In my case there are 14 rows for real, and that is what cma shows. But when I click a row on dgr1 - cma.position just displays...
2
1772
by: Viraptor | last post by:
Hello I've created a form with 2 listboxes. Both have data-binding. First one is "normal", 1:1 view of table. Second is filled using parameter from the first one. this.xxxTableAdapter.Fill(this.mainDataSet.XXX, (int)this.BindingContext.Current); When I do it in Form_Load() it shows first listbox with element with "id" of value 2 selected, but this.BindingContext.Current == 1. When I do the same thing in
2
10700
by: plmanikandan | last post by:
Hi, I am using .net framework2.0,Visual Studio 2005.I need to bind the hash table to datagridview.Is it possible I am having class Person class person { public int no; public string name; }
3
6328
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
New to databinding in vs2005, I always did it manually in 2003. I have no problem loading comboboxes, and a change in that combobox changes the data in the textboxes but I can not figure out a way to get the data in a datagridview to change. For example 2 columns are ID and amount_paid, the datagridview loads on form load with all ID's and amounts. How do I get it to only bring back the selected ID. Sounds like I may need to change the SQL...
1
2062
by: back100y | last post by:
I have an application where I am using a DataGridView control to display DataTables stored in a DataSet. What I need to do is be able to prevent a user from adding a new if there is already a certain number of rows in the table. In addition, when the user deletes a row I need to be able to see the contents of that row and modify other rows in the DataTable appropriately. From what I understand of the DataGridView controls interaction with...
0
1345
AHayes
by: AHayes | last post by:
I'm having an issue that I can't seem to find a solution to online...so I'm hopeful that someone here has the solution for me. _The Problem I'm using a DataGridView control to display information from a table. However, the table I'm showing also displays an ID that is used to link to another table. For instance, "BookID" in Table A ("TheLibrary") is used to link to Table B ("TheBooks") which has details about a given book with that ID. ...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.