Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

Here i'm facing problem with Datagridview control,i'm having dgvAllowance(Datagridview control name) in form2, now i want to call this datagrid in form1 button click event

How to do it

Thanks !
Posted
Updated 23-Apr-15 21:31pm
v2

have you tried to change the property "Modifiers" of data grid view?

e.g. change it from "private" to "public" and you are able to access the control with "form2.dgvAllowance"
 
Share this answer
 
Comments
OriginalGriff 24-Apr-15 3:55am    
That is seriously a bad idea - they are private for a reason.
What you suggest is against the principles of OOPs and makes your code a lot, lot harder to maintain or reuse.
Stoffy 24-Apr-15 4:48am    
i agree to your opinion. but it always depends on your goals and is related to the complexity of the solution.
prasanna.raj 24-Apr-15 5:17am    
oh it against the principles of OOPs ah, what is the best way for do this, is there any idea...i have googled by today morning for this issue...
Don't.
If you do that, you "lock" the design of the two forms together - so you cannot make changes to form2 without considering it's effects on form1 (and any other code which may also end up using it).

Instead, use properties of Form2 to provide the information back to form1, and methods in form2 to affect the DataGridView.
 
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