GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoControl Class
Members
In This Topic
    GoControl Class
    In This Topic
    This graphical object provides a way to get the appearance and behavior from an existing Windows Forms Control.
    Syntax
    [Serializable()]
    public class GoControl : GoObject 
    Remarks

    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 ControlType Type, and gives it the GoControl's GoObject.Bounds in view coordinates.

    This object keeps a hashtable mapping GoView's to Controls. 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 GoControls is as in-place editors for a GoObject. GoText for example, uses customized TextBox, ComboBox, and NumericUpDown Controls 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 GoControls 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 Controls. 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 Controls managed by the nested GoControls are in front of everything that the GoView paints.

    Besides having all Controls 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 Controls 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 Controls 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.

    See Also