Click here to Skip to main content
14,875,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to refresh a data grid view from another form. For Example Form 1 has Data grid view Control. I need to refresh the data grid view from form2 which is opened using form1. datagridview1.Refresh()is not working. please help
Posted
Comments
jerrykid 4-Jan-11 23:29pm
   
You meant to reload data into GridView?

Code on another form should not know nor care about controls on another form. Every form should stand on it's own without other forms manipulating its controls.

But, basically, you have to rebind the grid to the datasource. There is no "refresh" method on the DGV.
   
These two statements will do the actual trick:

MainForm.InvoicesBindingSource.ResetBindings(False)
MainForm.InvoicesDataGridView.Refresh()


This will do these two things:
(1)Causes your BindingSource on MainForm to rebind itself.
(2)Tells the InvoicesDataGridView to refresh itself

Hope this will help you.
   

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