C# Access A Form’s Controls Within A Class
Posted by DremationMay 16
There are a lot of beginner and even intermediate level developers that have no idea how to access/modify a forms objects/methods from within a different class. I’ll show you the easiest practice of this.
First we have to make a reference. We must use the ‘protected’ keyword. I use the same name as the windows form that way it is easy to keep track of variables.
Once that is done you must set each method and object you want to access to public. You do this from the Forms Designer Class.
And that’s it. With just 2 lines of code you can now access you forms controls and methods.
[Sorry for the images of the code, my code-box plugin is broken]
Popularity: unranked [?]


