BehaviorService::ControlToAdornerWindow Method (Control^)

 

Returns the location of a Control translated to adorner window coordinates.

Namespace:   System.Windows.Forms.Design.Behavior
Assembly:  System.Design (in System.Design.dll)

public:
Point ControlToAdornerWindow(
	Control^ c
)

Parameters

c
Type: System.Windows.Forms::Control^

The Control to translate.

Return Value

Type: System.Drawing::Point

A Point value indicating the location of c in adorner window coordinates.

The following code example is part of a larger example provided for the BehaviorService class.

public:
    virtual property Rectangle Bounds
    {
        Rectangle get() override
        {
            // Create a glyph that is 10x10 and sitting
            // in the middle of the control.  Glyph coordinates
            // are in adorner window coordinates, so we must map
            // using the behavior service.
            Point edge = behavior->ControlToAdornerWindow(control);
            Size size = control->Size;
            Point center = Point(edge.X + (size.Width / 2),
                edge.Y + (size.Height / 2));

            Rectangle bounds = Rectangle(center.X - 5,
                center.Y - 5, 10, 10);

            return bounds;
        }
    }

.NET Framework
Available since 2.0
Return to top
Show: