Updated: September 2010
Occurs when the control loses mouse capture.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
In rare scenarios, you might need to detect unexpected input. For example, consider the following scenarios.
During a mouse operation, the user opens the Start menu by pressing the Windows key or CTRL+ESC.
During a mouse operation, the user switches to another program by pressing ALT+TAB.
During a mouse operation, another program displays a window or a message box that takes focus away from the current application.
Mouse operations can include clicking and holding the mouse on a form or a control, or performing a mouse drag operation. If you have to detect when a form or a control loses mouse capture for these and related unexpected scenarios, you can use the event.
The following code example demonstrates the event for a Button control.
To test this example, run it in the debugger by pressing F5. Open the Output window in Visual Studio so that you can see when events are raised. Click the Button and notice the following output.
Now, click and hold the left mouse button on the Button control. While still clicking the mouse, press ALT+TAB to switch to another program. Notice that the event is raised enabling you to potentially handle this scenario. Depending on your actions, the MouseUp event might not be raised. You can also try this test with the Windows key or CTRL+ESC.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.