Adding controls to form on runtime with code outside of Form class.

I'm trying to develop a structure where a Numeric UpDown control is used to dictate how many groups of a specific arrangement of controls are created on a form during runtime. For each group, the contents are supposed to be attributes of an object with an external class, so obtaining the user's input would be easier.

First off, everything I'm finding on google uses the "this" reference, which wouldn't work considering this code would be outside of the Form class. What is "this" referring to exactly? I haven't found any concrete instance of a Form1 object in the code.

Also, is it even possible for me to use form controls (and gain access to the user's input into them) as attributes to an object? I.e: would MyObject.TextBoxControl.Text be a valid statement?

by joshmo62 via /r/csharp

Leave a Reply