Export (0) Print
Expand All

ITransformProvider.Move Method

Moves the control.

Namespace: System.Windows.Automation.Provider
Assembly: UIAutomationProvider (in uiautomationprovider.dll)

void Move (
	double x,
	double y
void Move (
	double x, 
	double y
function Move (
	x : double, 
	y : double
Not applicable.



Absolute screen coordinates of the left side of the control.


Absolute screen coordinates of the top of the control.

Exception typeCondition


If the CanMove property is false.

An object cannot be moved, resized, or rotated such that its resulting screen location would be completely outside the coordinates of its container and inaccessible to keyboard or mouse. For example, when a top-level window is moved completely off-screen or a child object is moved outside the boundaries of the container's viewport. In these cases the object is placed as close to the requested screen coordinates as possible with the top or left coordinates overridden to be within the container boundaries.

The following example shows one possible implementation of this method for a custom control that can be moved.

/// <summary>
/// Moves the provider to the specified position.
/// </summary>
/// <param name="x">The specified X screen coordinate.</param>
/// <param name="y">The specified Y screen coordinate</param>
void ITransformProvider.Move(double x, double y)
    int leftInt = (int)x;
    int topInt = (int)y;

    if (!((ITransformProvider)this).CanMove)
        throw new InvalidOperationException(
            "Operation cannot be performed.");

    // Move should never be allowed to place a control outside the 
    // bounds of its container; the control should always be accessible 
    // using the keyboard or mouse.
    // Use the bounds of the parent window to limit the placement 
    // of the custom control.
    int maxLeft = 10;
    int maxTop = 10;
    int maxRight = 
        this.customControl.formWidth - this.customControl.Width - 10;
    int maxBottom = 
        this.customControl.formHeight - this.customControl.Height - 10;

    if (leftInt < maxLeft)
        leftInt = 0;
    if (topInt < maxTop)
        topInt = 0;
    if (leftInt > maxRight)
        leftInt = maxRight;
    if (topInt > maxBottom)
        topInt = maxBottom;

    // Invoke control method on separate thread to avoid clashing with UI.
    // Use anonymous method for simplicity.
    this.customControl.Invoke(new MethodInvoker(delegate()
        this.customControl.Left = leftInt;
        this.customControl.Top = topInt;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2014 Microsoft