共用方式為


Shape.LostFocus 事件

發生於圖形失去焦點時發生。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
<BrowsableAttribute(True)> _
Public Event LostFocus As EventHandler
[BrowsableAttribute(true)]
public event EventHandler LostFocus
[BrowsableAttribute(true)]
public:
 event EventHandler^ LostFocus {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
[<BrowsableAttribute(true)>]
member LostFocus : IEvent<EventHandler,
    EventArgs>
JScript 不支援事件。

備註

當您將焦點變更使用鍵盤 (索引標籤、 SHIFT + TAB,等等),或藉由呼叫Select或SelectNextControl方法中,焦點事件發生順序如下:

Enter

GotFocus

Leave

LostFocus

當您將焦點變更使用滑鼠或藉由呼叫Focus方法中,焦點事件發生順序如下:

Enter

GotFocus

LostFocus

Leave

如需如何處理事件的詳細資訊,請參閱處理和引發事件

注意事項注意事項

請勿嘗試將焦點設在LostFocus事件處理常式。這樣可以讓您的應用程式或作業系統停止回應。

範例

下列範例顯示如何回應LostFocus事件處理常式中的事件。 此範例中您需要RectangleShape名 RectangleShape1 為表單上的控制項。

Private Sub RectangleShape1_LostFocus() 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;
        }

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)