I'm an MS Access programmer moving over to C#. In MsAccess I have a routine where I open create a new form in design view and then the routine populates it with controls based upon the fields present in a SqlServer table. Not only does it create the controls, it creates the default event handlers that I use. it's a great time saver.
So now i'm trying to do this in C#. I've got a routine which creates controls dynamically like this:
MyTextBox=new System.Windows.Forms.TextBox();
this.Controls.Add(MyTextBox);
My issue is that the controls aren't permanent. When I go back to the form design, none of the dynamically created controls are there. Is there a way to do this?
I think my last resort would be to make my routine open the .CS sourcecode file and write lines of C# code in there. But if there's an easier way to do it I'd like to know please.