I build a windows application as a POS system, and I want to add a function that let the users add new button in the windows. So after user input information, such as item name and price, the application will generate code to create a new button and add the code into MainForm.cs and MainForm.Designer.cs.

However, the change in the source code would not take effect until I stop the application and re-run compiled exe. Is that possible to make the application rebuild itself when it is still running? (i.e. the user can see the new button show up on the windows right after he/she input the information)

I have tried using Application.Restart(); and this.Refresh();, but it didn't work.