語言

ToolTip.Popup 活動

定義

發生在工具提示首次顯示之前。 這是該 ToolTip 職業的預設事件。

public:
 event System::Windows::Forms::PopupEventHandler ^ Popup;
public event System.Windows.Forms.PopupEventHandler Popup;
public event System.Windows.Forms.PopupEventHandler? Popup;
member this.Popup : System.Windows.Forms.PopupEventHandler 
Public Custom Event Popup As PopupEventHandler 

事件類型

範例

以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 Popup 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox。

要執行範例程式碼,請將其貼到包含一個 ToolTip 名為 ToolTip1的實例的專案中。 然後確保事件處理程式與事件 Popup 相關聯。

private void ToolTip1_Popup(Object sender, PopupEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "AssociatedWindow", e.AssociatedWindow );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "AssociatedControl", e.AssociatedControl );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "IsBalloon", e.IsBalloon );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ToolTipSize", e.ToolTipSize );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Popup Event" );
}
Private Sub ToolTip1_Popup(sender as Object, e as PopupEventArgs) _ 
     Handles ToolTip1.Popup

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "AssociatedWindow", e.AssociatedWindow)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "AssociatedControl", e.AssociatedControl)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "IsBalloon", e.IsBalloon)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ToolTipSize", e.ToolTipSize)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Popup Event")

End Sub

備註

每當顯示 ToolTip 時,事件 Popup 都會被觸發,無論是透過明確呼叫某 Show 個方法,或 ToolTip 是類別隱含顯示 ToolTip。 此活動可能會被取消。

在此事件中呼叫導致底層視窗代柄重建的屬性, IsBalloon例如,將拋出例外。

適用於

另請參閱