ToolboxComponentsCreatingEventHandler 代理人
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表處理 ComponentsCreating 事件的方法。
public delegate void ToolboxComponentsCreatingEventHandler(System::Object ^ sender, ToolboxComponentsCreatingEventArgs ^ e);
public delegate void ToolboxComponentsCreatingEventHandler(object sender, ToolboxComponentsCreatingEventArgs e);
type ToolboxComponentsCreatingEventHandler = delegate of obj * ToolboxComponentsCreatingEventArgs -> unit
Public Delegate Sub ToolboxComponentsCreatingEventHandler(sender As Object, e As ToolboxComponentsCreatingEventArgs)
參數
- sender
- Object
事件的來源。
範例
下列範例程式代碼提供一個方法,這個方法會附加 事件的事件處理程式ComponentsCreatingToolboxItem,以及ToolboxComponentsCreatingEventHandler事件處理程式方法,這個方法會寫入事件引發ComponentsCreating事件處理程式時接收新元件或元件Console之元件類型的名稱。
public:
[PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
void LinkToolboxComponentsCreatingEvent( ToolboxItem^ item )
{
item->ComponentsCreating +=
gcnew ToolboxComponentsCreatingEventHandler( this, &Form1::OnComponentsCreating );
}
private:
void OnComponentsCreating( Object^ sender, ToolboxComponentsCreatingEventArgs^ e )
{
// Displays ComponentsCreating event information on the Console.
Console::WriteLine( "Name of the class of the root component of " +
"the designer host receiving new components: " +
e->DesignerHost->RootComponentClassName );
}
public void LinkToolboxComponentsCreatingEvent(ToolboxItem item)
{
item.ComponentsCreating += new ToolboxComponentsCreatingEventHandler(this.OnComponentsCreating);
}
private void OnComponentsCreating(object sender, ToolboxComponentsCreatingEventArgs e)
{
// Displays ComponentsCreating event information on the Console.
Console.WriteLine("Name of the class of the root component of " +
"the designer host receiving new components: " +
e.DesignerHost.RootComponentClassName);
}
Public Sub LinkToolboxComponentsCreatingEvent(ByVal item As ToolboxItem)
AddHandler item.ComponentsCreating, AddressOf Me.OnComponentsCreating
End Sub
Private Sub OnComponentsCreating(ByVal sender As Object, ByVal e As ToolboxComponentsCreatingEventArgs)
' Displays ComponentsCreating event information on the Console.
Console.WriteLine(("Name of the class of the root component of the designer host receiving new components: " + e.DesignerHost.RootComponentClassName))
End Sub
備註
建立 ToolboxComponentsCreatingEventHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件。
擴充方法
GetMethodInfo(Delegate) |
取得表示特定委派所代表之方法的物件。 |