SimpleShape.LocationChanged 事件

,更改,发生形状的 Location 属性。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<BrowsableAttribute(True)> _
Public Event LocationChanged As EventHandler
[BrowsableAttribute(true)]
public event EventHandler LocationChanged
[BrowsableAttribute(true)]
public:
 event EventHandler^ LocationChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
[<BrowsableAttribute(true)>]
member LocationChanged : IEvent<EventHandler,
    EventArgs>
JScript 不支持事件。

备注

如果通过编程修改或用户交互更改 Location 属性,则将引发此事件。

有关如何处理事件的更多信息,请参见使用事件

示例

下面的示例演示如何在事件处理程序中响应 LocationChanged 事件。 此示例要求您具有名为 RectangleShape1 和 RectangleShape2 的两个 RectangleShape 控件在窗体上。

Private Sub RectangleShape1_LocationChanged(
  ) Handles RectangleShape1.LocationChanged

    ' If the second rectangle intersects with the first, move it.
    If RectangleShape1.ClientRectangle.IntersectsWith( 
      RectangleShape2.ClientRectangle) Then
        RectangleShape2.Location = New Point(RectangleShape1.Right, 
         RectangleShape1.Bottom)
    End If
End Sub
private void rectangleShape1_LocationChanged(object sender, System.EventArgs e)
{
    // If the second rectangle intersects with the first, move it.
    if (rectangleShape1.ClientRectangle.IntersectsWith(rectangleShape2.ClientRectangle))
    {
        rectangleShape2.Location = new Point(rectangleShape1.Right, 
            rectangleShape1.Bottom);
    }
}

.NET Framework 安全性

请参见

参考

SimpleShape 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

Line 和 Shape 控件简介 (Visual Studio)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)