Visual Studio 2010 Express, Windows Forms.
Have made myself my first little application which used a local database (a journal app).
First form (which load when app starts) shows every entry that has been made.
A “Add button” show up a new form, from where I can add a new entry.
Now, everything works this far.
But when I close the add form, after adding a new entry, the new entry isn’t displayed in the first form. I have to close the program and start it up again the see the new entry.
How can I refresh the data in the first form, when the add form closes?
Best regards from Denmark
First of all you must open your second form as dialog like
new FormAdd().ShowDialog(this);this will stop the code until FormAdd close, then you can reload the data as you load in form firs load.
your code will be like this
by the way you can use DialogResult for unnecessary prevent refreshs is user does not insert a record to db. in FormAdd code set DialogResult value and in main form use like this