Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not sure if, where or when I should use OnComponentChanging/Changed ev

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Hello all,

We have a custom container control that has some controls added to it automatically by a custom designer. The designer sets some default properties for the embedded controls using code similar to the following:
Code:
With TypeDescriptor.GetProperties(component).Find(name, True)
    .SetValue(component, value)
End With
The embedded controls are exposed as properties in the custom control so they are available at Design time with code similar to the following:
Code:
Private m_MyEmbeddedControl As CheckBox = Nothing
Public Property MyEmbeddedControl As CheckBox
    Get
        Return m_MyEmbeddedControl
    End Get
    Set(ByVal value As CheckBox)
        m_MyEmbeddedControl = value
    End Set
End Property 'MyEmbeddedControl
Additionally, some requested embedded control properties are exposed as properties in the custom container control itself with code similar to the following:
Code:
Public Property MyEmbeddedControlBackColor As Color
    Get
        Return Me.MyEmbeddedControl.BackColor
    End Get
    Set(ByVal value As Color)
        Me.MyEmbeddedControl.BackColor = value
    End Set
End Property 'MyEmbeddedControlBackColor
Since these changes to the embedded controls are all taking place at different times in the Design time environment, I am not sure when or even if I should be raising the OnComponentChanging and OnComponentChanged events.

1. Do I need to raise the OnComponentChanging and OnComponentChanged events in custom designer code
a. When I create the embedded controls in the custom container control
b. When I change embedded control properties in the custom designer after they have been created

2. Do I need to raise the OnComponentChanging and OnComponentChanged events in the custom container control for the embedded controls themselves (eg MyEmbeddedControl above)

3. Do I need to raise the OnComponentChanging and OnComponentChanged events in the custom container control for embedded control properties which have been exposed in the custom container control (eg MyEmbeddedControlBackColor above)

If someone could explain this a bit for me, I would greatly appreciate it! Thanks in advance for any ideas and/or suggestions!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top