Microsoft KB Archive/190512

= How To Read Extender Properties from a UserControl =

Article ID: 190512

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190512



SUMMARY
There are times when your UserControl needs to check the value of an Extender Property when your control loads. This example shows how to check the values of Extender Properties from inside the UserControl. As an author of a control, you should not attempt to set Extender Properties with code in the UserControl.



MORE INFORMATION
Extender properties are provided by the container your control is placed on, but they appear to be a seamless extension of your control. A UserControl object can access extender properties through its Extender object.

To access an extender property, you must make sure your control is sited on the container. When the ReadProperties event of a UserControl happens, the control should be sited. However it still may not have access to all the extender properties. Because of this, the best place to read the value of an extender property is from the controls Show event.

Step-by-Step Example
 Create a new ActiveX Control project. UserControl1 is created by default. Change the BackColor of the UserControl to a different color such as red.  Add the following code to the UserControl: Private Sub UserControl_Show Debug.Print "WhatsThisHelpID " & Extender.WhatsThisHelpID

Debug.Print "Tooltiptext " & Extender.ToolTipText Debug.Print "HelpContextID " & Extender.HelpContextID Debug.Print "Tag " & Extender.Tag Debug.Print "Name " & Extender.Name End Sub

 Close the UserControl's design and code windows. From the File Menu, select Add Project, and add a Standard EXE project. Form1 is created by default. Make the Standard EXE project the Startup project by choosing Properties from the Project menu and, on the General tab, pick Form1 as the Startup Object. Place an instance of the UserControl on Form1. You will see a list of Extender properties in the Immediate Window.</li>  Set the following properties for UserControl1 on Form1: WhatsThisHelpID = 101 HelpContextID= 101 Tag = "MyControl" ToolTipText = "Usercontrol" Name = "Bubba"

</li> Save and run the project group. In the Immediate window you will see the new values for the different Extender properties.</li></ol>

<div class="references_section">