Hi, I am interested in detecting when a GoObject is added to the view that is “watching” a document.
The addition of the objects is done with GoDocument.Add(…), but the problem appears when adding custom GoControls (which embbed for example a TrackBar control). I am interesting in pre-setting this control (trackbar) after addition (e.g. setting the bar position), however the reference of the trackbar object in the GoControl object is not valid until the later is added to the view.
Any help / suggestion is greatly appreciated
All the best
Paul
Yes, that’s right–the Windows.Forms.Control can’t exist until there’s a container (a GoView) to hold it. GoDocuments and GoObjects have an existence that is not tied to any Control or Form. (They are also Serializable, whereas WinForms Controls are not.)
And since there can be many GoViews viewing a GoDocument, if that GoDocument has a GoControl in it, there might be many WinForms Controls for that one GoControl object.
The most general way of doing initialization to override GoControl.CreateControl.
But more commonly one implements the IGoControlObject interface in a subclass of your Control. In the IGoControlObject.GoControl setter you can do all the initialization that you want. You’ll want to look at the GoControl’s parent node to find the application-specific information you need for that particular instance of a Control.