473,513 Members | 2,558 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.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

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

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**@discussions.microsoft.com> schreef in bericht
news:99**********************************@microsof t.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

May 26 '06 #3

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

Similar topics

3
1980
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...
10
1863
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...
8
3914
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...
2
3242
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...
2
1766
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. ...
2
10680
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
6308
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...
1
2037
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...
0
1333
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...
0
7161
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
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,...
0
7539
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...
0
7525
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...
0
4746
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...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.