How do I incorporate classes into a Visual C# form?
Incorporating classes is just a matter of opening the form file in code view and declaring a variable of the type you wish to use:
private MyClass my = new MyClass();
If you're wondering why you can drop some things that are not controls on the form, it's because they're not regular classes but rather Components, which only differ with classes in that they inherit from a Component base class (directly or indirectly), which gives them more freedom to interact with the design-time form.
You won't see your variables (of regular classes) in design view, as they are just that, variables that have nothing to do with the form, unlike components, which are hooked to a form automatically by the InitializeComponent method (among other things).
Dig Deeper on C# programming language
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.