Shape.GotFocus 事件

,当形状接收焦点,发生。

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

语法

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

备注

使用键盘 (可选, SHIFT+TAB,当您更改焦点,等等) 时,或调用 Select 或 SelectNextControl 方法,焦点事件按以下顺序发生:

Enter

GotFocus

Leave

LostFocus

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

Enter

GotFocus

LostFocus

Leave

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

备注

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

示例

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

Private Sub RectangleShape1_GotFocus(
  ) Handles RectangleShape1.GotFocus

    RectangleShape1.SelectionColor = Color.Red
End Sub
private void rectangleShape1_GotFocus(object sender, System.EventArgs e)
{
    rectangleShape1.SelectionColor = Color.Red;
}

.NET Framework 安全性

请参见

参考

Shape 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

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

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

Line 和 Shape 控件简介 (Visual Studio)