Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have inserted an MDIParent form in my project. There is a datagridview on it. When I add data to it (on parent form) and then open a child form through Parnet form, it displays the datagridview, which it should but there are two unwanted things:

1) It also takes all the data which I entered on Parent form's datagrid view

2) When I make change to data on child form, the effect also transfers to the parent form's datagridview.

Please advise how to make controls on parent forms the data changes of which limit to the current form only, not on all children and parent forms.
Thanks


[edit]unnecessary code block removed[/edit]
Posted
Updated 17-Jun-13 0:30am
v2
Comments
Simon_Whale 17-Jun-13 6:39am    
how are you connecting the data to the grids? are they sharing a variable etc?
Furqan Sehgal 17-Jun-13 7:15am    
I just tired it adding data directly from the keyboard
PrissySC 18-Jun-13 18:16pm    
Are you using a common bindingsource for each data grid? If so, they will bind to the bindingsource and changes made to the bindingsource are what the grids both will display. Two bindingsources will stop this, but if you need to link the data you will have to consider how to handle the datamembers or make updates if needed to the child or parent grid.

Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

I can explain what to do instead. Please see my past answers:
How to Create MDI Parent Window in WPF? [Solution 2],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

—SA
 
Share this answer
 
Comments
Maciej Los 6-Aug-13 16:09pm    
Matrix? I think i have seen this answer million times and i see it over and over again ;)
+5!
Sergey Alexandrovich Kryukov 6-Aug-13 16:13pm    
Thank you, Maciej.
Yes, but this is because the inquirers won't read old answer...
—SA
Maciej Los 6-Aug-13 16:22pm    
So, the question is: who need CP's rules? You, me and few of "old" CP members...
Sergey Alexandrovich Kryukov 6-Aug-13 16:25pm    
People systematically ignoring essential rules should be let go; as simple as that. For the sake of other, well-intended members.

However, I cannot say anything negative about Furqan Sehgal in connection to the current question: my post is something which OP could not expect and try to find. There is a misconception that MDI is acceptable. My advice is of the unsolicited type, but I just think it's practically useful.

—SA
Use different binding source. If u r using same binding source then this problem can arise. When you update any of the grid then the common table adapter gets filled (updated) and so u r getting effects in both of grids.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900