Control.OnMove(EventArgs) 方法

定义

引发 Move 事件。

C#
protected virtual void OnMove(EventArgs e);

参数

e
EventArgs

包含事件数据的 EventArgs

示例

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

C#
// 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();
}

注解

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

OnMove 方法还允许派生类对事件进行处理而不必附加委托。 这是在派生类中处理事件的首选技术。

继承者说明

在派生类中重写 OnMove(EventArgs) 时,一定要调用基类的 OnMove(EventArgs) 方法,以便已注册的委托对事件进行接收。

适用于

产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另请参阅