ToolboxComponentsCreatedEventHandler Delegate
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents the method that handles the ComponentsCreated event.
public delegate void ToolboxComponentsCreatedEventHandler(System::Object ^ sender, ToolboxComponentsCreatedEventArgs ^ e);
public delegate void ToolboxComponentsCreatedEventHandler(object sender, ToolboxComponentsCreatedEventArgs e);
type ToolboxComponentsCreatedEventHandler = delegate of obj * ToolboxComponentsCreatedEventArgs -> unit
Public Delegate Sub ToolboxComponentsCreatedEventHandler(sender As Object, e As ToolboxComponentsCreatedEventArgs)
Parameters
- sender
- Object
The source of the event.
A ToolboxComponentsCreatedEventArgs that provides data for the event.
Examples
The following example code provides a method that attaches an event handler for the ComponentsCreated event of a ToolboxItem. It also provides a ToolboxComponentsCreatedEventHandler event handler method that writes the name of the type of the components that were created to the Console when the event handler is raised by a ComponentsCreated event.
public:
[PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
void LinkToolboxComponentsCreatedEvent( ToolboxItem^ item )
{
item->ComponentsCreated +=
gcnew ToolboxComponentsCreatedEventHandler( this, &Form1::OnComponentsCreated );
}
private:
void OnComponentsCreated( Object^ sender, ToolboxComponentsCreatedEventArgs^ e )
{
// Lists created components on the Console.
for ( int i = 0; i < e->Components->Length; i++ )
{
Console::WriteLine( "Component #" + i + ": " +
e->Components[ i ]->Site->Name );
}
}
public void LinkToolboxComponentsCreatedEvent(ToolboxItem item)
{
item.ComponentsCreated += new ToolboxComponentsCreatedEventHandler(this.OnComponentsCreated);
}
private void OnComponentsCreated(object sender, ToolboxComponentsCreatedEventArgs e)
{
// Lists created components on the Console.
for( int i=0; i< e.Components.Length; i++ )
Console.WriteLine("Component #"+i.ToString()+": "+e.Components[i].Site.Name.ToString());
}
Public Sub LinkToolboxComponentsCreatedEvent(ByVal item As ToolboxItem)
AddHandler item.ComponentsCreated, AddressOf Me.OnComponentsCreated
End Sub
Private Sub OnComponentsCreated(ByVal sender As Object, ByVal e As ToolboxComponentsCreatedEventArgs)
' Lists created components on the Console.
Dim i As Integer
For i = 0 To e.Components.Length - 1
Console.WriteLine(("Component #" + i.ToString() + ": " + e.Components(i).Site.Name.ToString()))
Next i
End Sub
Remarks
When you create a ToolboxComponentsCreatedEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Handling and Raising Events.
Extension Methods
GetMethodInfo(Delegate) |
Gets an object that represents the method represented by the specified delegate. |