This documentation is archived and is not being maintained.

Control.OnMove Method

Raises the Move event.

[Visual Basic]
Protected Overridable Sub OnMove( _
   ByVal e As EventArgs _
)
[C#]
protected virtual void OnMove(
 EventArgs e
);
[C++]
protected: virtual void OnMove(
 EventArgs* e
);
[JScript]
protected function OnMove(
   e : EventArgs
);

Parameters

e
An EventArgs that contains the event data.

Remarks

Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

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.

Notes to Inheritors:  When overriding OnMove in a derived class, be sure to call the base class's OnMove method so that registered delegates receive the event.

Example

[Visual Basic] 
' 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

[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();
}

[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 = String::Format( S"Form screen position = {0}", __box(this->Location));
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | Move

Show: