0
votes

i use visual studio 2012 c#. I tried to do something but unfortunately it's not working.

My problem:

I have a form with two datagridviews: one should be master and the other details(clone).

1-) such that When a row is selected in the master datagridview, the detail or clone datagridview is populated with data pertaining to the selected row.

2-) Secondly, What I am want to do is print (display) the master datagridview and each of the corresponding detail datagridviews. My legacy application already has printing capability so I'm trying to use that. I've created an array of the datagridviews and printed them, but all the detail datagridviews are the same because they were copied by reference.

Any help is welcome.

1
which technology : winforms/wpf ?AnjumSKhan
Your question seems unclear and has contradictions. How is a Details DGV a 'clone' of the master??? And do you have two DGvs or several (' the master datagridview and each of the corresponding detail datagridviews'). What aspect do you want to 'clone' anyway? Layout, Style? Data? Behaviour? Also how is priting the same as displaying?? As it stands this qustion is both unlcear, too braod and also off-topic.TaW
Sounds less like cloning and more like a master-detail relationship. One example (if you are working with data from a database) is to populate a DataSet with both the master and detail data then set relations between the two DataTables in the DataSet via DataSet.SetRelation. If you really want display the same data in both DataGridView controls then that can be done but does not seem right in how you phrased in your question about details. It would be great if you could supply more details e.g. what is the data source and logic of master to detail.Karen Payne

1 Answers

1
votes

Try using:

currencyManager = (CurrencyManager)dataGridView1.BindingContext[data];