Export (0) Print
Expand All

Visual Basic Reference

Visual Studio 6.0

VBControlExtender Object

See Also    Example    Properties    Methods    Events

Represents the Visual Basic VBControlExtender properties.

Syntax

VBControlExtender

Remarks

The VBControlExtender object is primarily used when dynamically adding a control to the Controls collection using the Add method. The VBControlExtender object is particularly useful for this purpose because it provides a generic set of properties, events, and methods to the developer. Another feature of the object is the ObjectEvent event which is designed to parse any event raised by a dynamically added control. The example below declares an object variable as VBControlExtender, and sets the variable when adding a control. The example also shows how you can program the ObjectEvent event.

Option Explicit
Dim WithEvents objExt As VBControlExtender ' Declare VBControlExtender variable WithEvents

Private Sub LoadControl()
   Licenses.Add "Project1.Control1", "ewrinvcmcoe"
   Set objExt = Controls.Add("Project1.Control1", "myCtl")
   objExt.Visible = True ' The control is invisible by default.
End Sub

Private Sub extObj_ObjectEvent(Info As EventInfo)
   ' Program the events of the control using Select Case.
   Select Case Info.Name
   Case "Click"
      ' Handle Click event here.
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub

Restrictions on Setting the References to the Variable

There is one caveat to be aware of when setting the VBControlExtender object to a dynamically added control: intrinsic controls cannot be set to the variable.

Show:
© 2015 Microsoft