GetOrCreate Method


All cControl / cControl_EventHandler objects are initialized with a reference to a control object, whether it's an ActiveX control or another Composite Controls control. Using this reference the GetOrCreate method ensures that only one instance of a particular type of Composite Control is created for each control reference. Thus, if a Composite Control of the requested type has already been created for the passed reference, GetOrCreate simply returns a reference to the applicable Composite Control. If not, a new one is created and returned.

Syntax

object.GetOrCreate(Control_Reference, ControlType, InitializeObject)

object A reference to a valid cCompositeControlManager class instance.

Parameters

Name Required / Optional Data Type Description
Control_Reference Required Object Reference to the control managed by a new or existing Composite Control object.
ControlType Optional ccControlType Enumeration describing the control type. If omitted, the default control type for the CompositeControlManager object (defined upon initialization) is used.
InitializeObject Optional Boolean Indicates whether the new object is to be intialized automatically. Default is true.

Remarks

Most Composite Controls initialize with only one parameter, the control reference. For initializations that require more parameters, InitializeObject should be False.

Example

This example creates a new event handler object and returns a reference to it. Assumes there is an open form, My Form, with a combo box object, MyComboBox.

Dim myEventHandler as cControl_EventHandler_ComboBox

Set myEventHandler = CompositeControls.EventHandlers.GetOrCreate([Form_My Form].MyComboBox, ccCombobox_EventHandler)

Last edited Dec 30, 2010 at 2:22 AM by vba_junkie, version 2

Comments

No comments yet.