I have two forms. Form A and Form B.
Form A has a datagrid that is populated from a SQL Database Table query. When a button is pressed Form B is launched that allows you to add a record to the database table. I need for the datagrid to be refreshed and show the newly added record when I close form B and go back to the parent.

I thought this would be easy, but it has been giving me fits.

I'm using a SQL Query to populate the DataGridView control, but I need to Requery the table again to repopulate it I think.

Can anyone give me any suggestions on how to do this?

I was looking for a way to re-fire the form load event but I can't figure out how.

Any help would be appreciated,

Thanks in advance,

Recommended Answers

All 2 Replies

You shouldnt call the Load event at all to be honest. Calling the load event at runtime will have sometimes very bad side effects.
Put your code for filling the datagrid in a seperate function and call this function in the load event of FormA and from FormB u call it FormA.myFunction

Thank you so much for this post. After creating a custom function to populate the datagridview control it was very easy for me to fire it from outside the form.

Thanks So Much!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.