Control.OnMove(EventArgs) Control.OnMove(EventArgs) Control.OnMove(EventArgs) Control.OnMove(EventArgs) Method

定义

引发 Move 事件。Raises the Move event.

protected:
 virtual void OnMove(EventArgs ^ e);
protected virtual void OnMove (EventArgs e);
abstract member OnMove : EventArgs -> unit
override this.OnMove : EventArgs -> unit
Protected Overridable Sub OnMove (e As EventArgs)

参数

e
EventArgs EventArgs EventArgs EventArgs

包含事件数据的 EventArgsAn EventArgs that contains the event data.

示例

下面的代码示例使用Move事件在窗体的标题栏中显示窗体的位置(以屏幕坐标表示)。The following code example uses the Move event to display the location of the form in screen coordinates on the caption bar of the form.

   // The following example displays the location of the form in screen coordinates
   // on the caption bar of the form.
private:
   void Form1_Move( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      this->Text = String::Format( "Form screen position = {0}", this->Location );
   }
// The following example displays the location of the form in screen coordinates
// on the caption bar of the form.
private void Form1_Move(object sender, System.EventArgs e)
{
    this.Text = "Form screen position = " + this.Location.ToString();
}
' The following example displays the location of the form in screen coordinates
' on the caption bar of the form.
Private Sub Form1_Move(sender As Object, e As System.EventArgs) Handles MyBase.Move
    Me.Text = "Form screen position = " + Me.Location.ToString()
End Sub

注解

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息, 请参阅处理和引发事件For more information, see Handling and Raising Events.

OnMove 方法还允许派生类对事件进行处理而不必附加委托。The OnMove method also allows derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.

继承者说明

在派生类中重写 OnMove(EventArgs) 时,一定要调用基类的 OnMove(EventArgs) 方法,以便已注册的委托对事件进行接收。When overriding OnMove(EventArgs) in a derived class, be sure to call the base class's OnMove(EventArgs) method so that registered delegates receive the event.

适用于

另请参阅