Northwoods.Go Assembly > Northwoods.Go Namespace : GoControl Class |
Control
.'Declaration <SerializableAttribute()> Public Class GoControl Inherits GoObject
[SerializableAttribute()] public class GoControl : GoObject
A GoControl
is a GoObject that manages a Windows Forms Control
in a GoView. The Control
is automatically created when the GoObject becomes visible in the view, and is added to the view's Controls
collection. By default the Control
has the same size as the GoControl
, and it moves around or changes size on the screen as the GoControl
is scrolled around or resized.
CreateControl is responsible for creating an instance of a Control
. By default it just creates an instance of the ControlTypeType
, and gives it the GoControl's GoObject.Bounds in view coordinates.
This object keeps a hashtable mapping GoView's to Control
s. FindControl finds any Control
for this GoControl
in a given GoView. GetControl is responsible for making sure a Control
exists; if FindControl returns null, it calls CreateControl.
The most common use of GoControl
s is as in-place editors for a GoObject. GoText for example, uses customized TextBox
, ComboBox
, and NumericUpDown
Control
s to allow the user to edit text. When used as an editor, a GoControl
is added to a GoView layer, not to a document. The use of the Control
managed by the GoControl
is effectively modal. The EditedObject property is used when this GoControl
is used as a GoObject editor. This GoControl
becomes the value of GoView.GoView.EditControl.
However, you can also use GoControl
s in GoDocuments. When they are used as regular document objects, usually as part of a GoGroup, a Control
is created for each GoView in which the GoControl
can be seen. Please be aware of the restrictions that are imposed by Windows Controls. Because each Control
, including GoView, is responsible for completely painting itself and handling all events that it receives, it is not possible to interleave the painting done by GoView and the painting done by Control
s. All Controls
that are parented by a GoView must appear in front of the GoView itself. Hence two GoGroups that each contain a GoControl and that overlap each other will produce the odd effect of not having one group properly appear in front of the other one, because the Control
s managed by the nested GoControls are in front of everything that the GoView paints.
Besides having all Control
s appear in front of all GoObjects, the use of GoControl has additional limitations and difficulties of use. You will need to handle the initialization of the Control
, given information that is present on or accessible from the GoControl or its GoObject.Parent or GoObject.ParentNode. This is often done in the IGoControlObject.GoControl setter, if you subclass the Control
and implement the IGoControlObject interface. Or you can do the initialization in a call from an override of CreateControl.
Another limitation is that your application will need to deal with focus issues, scaling, and printing, and synchronization. Printing, in particular, is not naturally supported by Windows Forms controls. And at the current time, scaling Control
s is not performed in a good manner. And if you have a GoControl
visible in two GoViews at the same time, you will need to deal with synchronization issues between the two Control
s that are created for the single GoControl
object.
For simplicity, Paint does not call GetControl to make sure a Control
exists in a GoOverview. Instead it just paints a gray rectangle.
System.Object
Northwoods.Go.GoObject
Northwoods.Go.GoControl
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2