Reputation: 345
I am new to the GUI side of C# and I have been unit testing this C# Application.
I have been trying to use a class constructor which asks for a Control
type object and a bool
.
I have been trying to read about the Control
class and I could not understand what it is.
I would highly appreciate it if somebody could explain to me in simple terms what Control
class is and what it's relation to Forms.
Upvotes: 1
Views: 4634
Reputation: 1078
I guess this is actually a while back, to make things simple for you think of a Control Class as a class that contains all visual elements for your GUI. If you need a scroll bar all you do is inherit from that class by instantiating an object which you use to create the graphical representation of your scroll bar. Now, that graphical representation(scrollbar or button ...) provides the UI for you to implement(control) your business logic on how you will interact with data.
Upvotes: 0
Reputation: 425
Windows forms is build upon a object hierarchy. All the UI controls that use a ControlTemplate to define their appearance is inherited from Control class. In OO this type of parent class inheritance is called as base class.
if you look at the Object Hierarchy it looks as follows
- System.Windows.Forms.Control
-System.Windows.Forms.ScrollableControl
-System.Windows.Forms.ContainerControl
-System.Windows.Forms.Form
So Form is a Control. Whatever Control can do Form can do it too because its inherited. Hope it clears out your question.
Upvotes: 2
Reputation: 353
From MSDN:
Defines the base class for controls, which are components with visual representation.
Basically it is the base class for all visual components. TextBox, DropDown etc... It has basic functions and methods to define Visibility, Size etc.
Upvotes: 0