Controls:-----------
Most controls in .NET derive from the System.Windows.Forms.Control class. This class defines the basic functionality of the controls, which is why many properties and events in the controls we'll see are identical. Many of these classes are themselves base classes for other controls, as is the case with the Label and TextBoxBase classes:--
Some controls, named custom or user controls, derive from another class: System.Windows.Forms.UserControl. This class is itself derived from the Control class and provides the functionality we need to create controls ourselves. We'll cover this class in Chapter 14. Incidentally, controls used for designing Web user interfaces derive from yet another class, System.Web.UI.Control.
Properties
All controls have a number of properties that are used to manipulate the behavior of the control. The base class of most controls, Control, has a number of properties that other controls either inherit directly or override to provide some kind of custom behavior.
The table below shows some of the most common properties of the Control class. These properties will be present in most of the controls we'll visit in this chapter, and they will therefore, not be explained in detail again, unless the behavior of the properties is changed for the control in question. Note that this table is not meant to be exhaustive; if you want to see all f the properties in the class, please refer to the MSDN library:
Name Availability Description
Anchor Read/Write Using this property, you can specify how the control
behaves when its container is resized. See below for a detailed explanation of this property.
BackColor Read/Write The background color of a control.
Bottom Read/Write By setting this property, you specify the distance
from the top of the window to the bottom of the control. This is not the same as specifying the height of the control.
Dock Read/Write Allows you to make a control dock to the edges of a
window. See below for a more detailed explanation of this property.
Enabled Read/Write Setting Enabled to true usually means that the control
can receive input from the user. Setting Enabled to false usually means that it cannot.
ForeColor Read/Write The foreground color of the control.
Height Read/Write The distance from the top to the bottom of the control.
Left Read/Write The left edge of the control relative to the left
edge of the window.
Name Read/Write The name of the control. This name can be used to reference the control in code.
Parent Read/Write The parent of the control.
Right Read/Write The right edge of the control relative to the left
edge of the window.
TabIndex Read/Write The number the control has in the tab order of its container.
TabStop Read/Write Specifies whether the control can be accessed by the Tab key.
Tag Read/Write This value is usually not used by the control itself,
and is there for you to store information about the control on the control itself. When this property is assigned a value through the Windows Form designer, you can only assign a string to it.
Top Read/Write The top edge of the control relative to the top of the window.
Visible Read/Write Specifies whether or not the control is visible
at runtime.
Width Read/Write The width of the control.
Most controls in .NET derive from the System.Windows.Forms.Control class. This class defines the basic functionality of the controls, which is why many properties and events in the controls we'll see are identical. Many of these classes are themselves base classes for other controls, as is the case with the Label and TextBoxBase classes:--
Some controls, named custom or user controls, derive from another class: System.Windows.Forms.UserControl. This class is itself derived from the Control class and provides the functionality we need to create controls ourselves. We'll cover this class in Chapter 14. Incidentally, controls used for designing Web user interfaces derive from yet another class, System.Web.UI.Control.
Properties
All controls have a number of properties that are used to manipulate the behavior of the control. The base class of most controls, Control, has a number of properties that other controls either inherit directly or override to provide some kind of custom behavior.
The table below shows some of the most common properties of the Control class. These properties will be present in most of the controls we'll visit in this chapter, and they will therefore, not be explained in detail again, unless the behavior of the properties is changed for the control in question. Note that this table is not meant to be exhaustive; if you want to see all f the properties in the class, please refer to the MSDN library:
Name Availability Description
Anchor Read/Write Using this property, you can specify how the control
behaves when its container is resized. See below for a detailed explanation of this property.
BackColor Read/Write The background color of a control.
Bottom Read/Write By setting this property, you specify the distance
from the top of the window to the bottom of the control. This is not the same as specifying the height of the control.
Dock Read/Write Allows you to make a control dock to the edges of a
window. See below for a more detailed explanation of this property.
Enabled Read/Write Setting Enabled to true usually means that the control
can receive input from the user. Setting Enabled to false usually means that it cannot.
ForeColor Read/Write The foreground color of the control.
Height Read/Write The distance from the top to the bottom of the control.
Left Read/Write The left edge of the control relative to the left
edge of the window.
Name Read/Write The name of the control. This name can be used to reference the control in code.
Parent Read/Write The parent of the control.
Right Read/Write The right edge of the control relative to the left
edge of the window.
TabIndex Read/Write The number the control has in the tab order of its container.
TabStop Read/Write Specifies whether the control can be accessed by the Tab key.
Tag Read/Write This value is usually not used by the control itself,
and is there for you to store information about the control on the control itself. When this property is assigned a value through the Windows Form designer, you can only assign a string to it.
Top Read/Write The top edge of the control relative to the top of the window.
Visible Read/Write Specifies whether or not the control is visible
at runtime.
Width Read/Write The width of the control.