RefreshEventHandler 代理人

定義

表示當 Refreshed 或元件在設計階段期間變更時,會處理所引發 Type 事件的方法。Represents the method that handles the Refreshed event raised when a Type or component is changed during design time.

public delegate void RefreshEventHandler(RefreshEventArgs ^ e);
public delegate void RefreshEventHandler(RefreshEventArgs e);
type RefreshEventHandler = delegate of RefreshEventArgs -> unit
Public Delegate Sub RefreshEventHandler(e As RefreshEventArgs)

參數

e
RefreshEventArgs

RefreshEventArgs,含有已變更的元件或 TypeA RefreshEventArgs that contains the component or Type that changed.

繼承
RefreshEventHandler

範例

下列範例示範如何在類型或元件變更時,使用 RefreshEventHandler 委派來處理 Refreshed 事件。The following sample demonstrates how to use a RefreshEventHandler delegate to handle the Refreshed event when a type or component changes. 在程式碼中,OnRefreshed 事件會處理事件,並顯示正在變更的元件。In the code, the OnRefreshed event handles the event and displays the component being changed.

此程式碼假設 TextBox 控制項已放置在表單上。The code assumes that a TextBox control is already sited on the form.

private:
   void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      textBox1->Text = "changed";
      System::ComponentModel::TypeDescriptor::Refreshed += gcnew System::ComponentModel::RefreshEventHandler( OnRefresh );
      System::ComponentModel::TypeDescriptor::GetProperties( textBox1 );
      System::ComponentModel::TypeDescriptor::Refresh( textBox1 );
   }

protected:
   static void OnRefresh( System::ComponentModel::RefreshEventArgs^ e )
   {
      Console::WriteLine( e->ComponentChanged );
   }
private void Form1_Load(object sender, System.EventArgs e)
{
    textBox1.Text = "changed";
    System.ComponentModel.TypeDescriptor.Refreshed += new
    System.ComponentModel.RefreshEventHandler(OnRefresh);
    System.ComponentModel.TypeDescriptor.GetProperties(textBox1);
    System.ComponentModel.TypeDescriptor.Refresh(textBox1);
}

protected static void OnRefresh(System.ComponentModel.RefreshEventArgs e)
{
    Console.WriteLine(e.ComponentChanged.ToString());
}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    TextBox1.Text = "changed"
    AddHandler System.ComponentModel.TypeDescriptor.Refreshed, AddressOf OnRefreshed
    System.ComponentModel.TypeDescriptor.GetProperties(TextBox1)
    System.ComponentModel.TypeDescriptor.Refresh(TextBox1)
End Sub

Private Sub OnRefreshed(ByVal e As System.ComponentModel.RefreshEventArgs)
    Console.WriteLine(e.ComponentChanged.ToString())
End Sub

備註

建立 RefreshEventHandler 委派時,必須識別處理事件的方法。When you create a RefreshEventHandler delegate, you identify the method that will handle the event. 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。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.

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。Gets an object that represents the method represented by the specified delegate.

適用於

另請參閱