Control.OnMove(EventArgs) 方法

定义

引发 Move 事件。

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

示例

下面的代码示例使用 Move 事件在窗体标题栏上的屏幕坐标中显示窗体的位置。

   // 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

注解

引发事件会通过委托调用事件处理程序。 有关详细信息,请参阅 处理和引发事件

该方法 OnMove 还允许派生类在不附加委托的情况下处理事件。 这是处理派生类中的事件的首选技术。

继承者说明

在派生类中重写 OnMove(EventArgs) 时,请务必调用基类的方法,以便已注册的 OnMove(EventArgs) 委托接收事件。

适用于

另请参阅