This documentation is archived and is not being maintained.

TemplatedControlDesigner.OnComponentChanged Method

A delegate that handles the component changed event.

[Visual Basic]
Overrides Public Sub OnComponentChanged( _
   ByVal sender As Object, _
   ByVal ce As ComponentChangedEventArgs _
)
[C#]
public override void OnComponentChanged(
 object sender,
 ComponentChangedEventArgs ce
);
[C++]
public: void OnComponentChanged(
 Object* sender,
 ComponentChangedEventArgs* ce
);
[JScript]
public override function OnComponentChanged(
   sender : Object,
 ce : ComponentChangedEventArgs
);

Parameters

sender
The object sending the event.
ce
A ComponentChangedEventArgs that provides data for the event.

Remarks

This is called after a property has been changed. It allows the implementor to do any post-processing that may be needed after a property change.

Example

[Visual Basic] The following code example overrides the OnComponentChanged method to check the name of the property that changed. If the name was DataSource or DataMember, then a custom method, named OnDataSourceChanged, is called that sets the data table used at design time to a null reference (Nothing in Visual Basic). If the name was ItemStyle, then a custom method, named OnStylesChanged, is called that in turn calls a method that notifies the designer that the template editing verbs collection associated with the designer has changed.

[Visual Basic] 
' Override the OnComponentChanged method to change
' the control's DataSource or styles in the designer.
Public Overrides Sub OnComponentChanged(sender As Object, e As ComponentChangedEventArgs)
   If Not (e.Member Is Nothing) Then
      Dim memberName As String = e.Member.Name
      If memberName.Equals("DataSource") Or memberName.Equals("DataMember") Then
         OnDataSourceChanged()
      Else
         If memberName.Equals("ItemStyle") Then
            OnStylesChanged()
         End If
      End If
   End If 
   MyBase.OnComponentChanged(sender, e)
End Sub

' Create a method that sets the data table 
' associated with the templates to nothing.
Protected Overridable Sub OnDataSourceChanged()
   designTimeDataTable = Nothing
End Sub

' Create a method that determines whether the designer
' verbs associated with the control's templates have
' changed.
Protected Sub OnStylesChanged()
   OnTemplateEditingVerbsChanged()
End Sub

' Create a method that notifies all callers
' that the designer verbs collection has changed.
Protected Sub OnTemplateEditingVerbsChanged()
   templateVerbsDirty = True
End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

TemplatedControlDesigner Class | TemplatedControlDesigner Members | System.Web.UI.Design Namespace

Show: