Shape.LostFocus 事件

更新:2007 年 11 月

当形状失去焦点时发生。

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

语法

声明
<BrowsableAttribute(True)> _
Public Event LostFocus As EventHandler
用法
Dim instance As Shape
Dim handler As EventHandler

AddHandler instance.LostFocus, handler
[BrowsableAttribute(true)]
public event EventHandler LostFocus
[BrowsableAttribute(true)]
public:
 event EventHandler^ LostFocus {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
JScript 不支持事件。

备注

当使用键盘(Tab、Shift+Tab 等)或者通过调用 Select 或 SelectNextControl(Shape, Boolean, Boolean, Boolean, Boolean) 方法更改焦点时,焦点事件将按以下顺序发生:

Enter

GotFocus

Leave

LostFocus

当使用鼠标或通过调用 Focus 方法更改焦点时,焦点事件将按以下顺序发生:

Enter

GotFocus

LostFocus

Leave

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

说明:

请不要尝试在 LostFocus 事件处理程序中设置焦点。 否则会导致应用程序或操作系统停止响应。

示例

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

Private Sub RectangleShape1_LostFocus(ByVal sender As Object, _
 ByVal e As System.EventArgs) Handles RectangleShape1.LostFocus
    ' Restore the default BorderColor.
    RectangleShape1.BorderColor = _
      PowerPacks.SimpleShape.DefaultBorderColor
End Sub
private void rectangleShape1_LostFocus(object sender, System.EventArgs e)
{
    // Restore the default BorderColor.
    rectangleShape1.BorderColor = SimpleShape.DefaultBorderColor;
}

权限

另请参见

参考

Shape 类

Shape 成员

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

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

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

Line 和 Shape 控件简介 (Visual Studio)