2014-06-25 34 views
2

我有一個窗體窗體應用程序,其中一些控件首先隱藏並在某些情況下可見。 有時候工具提示氣球不可見。 我有以下構造函數代碼,工具提示氣球沒有顯示在獲勝形式的控件

ToolTip toolTipBalloon; 
toolTipBalloon.AutoPopDelay = 15000; 
toolTipBalloon.InitialDelay = 1500; 
toolTipBalloon.IsBalloon = true; 
toolTipBalloon.ReshowDelay = 100; 
toolTipBalloon.ToolTipTitle = "Setting"; 
toolTipBalloon.Popup += new System.Windows.Forms.PopupEventHandler(this.toolTipBalloon_Popup); 

在事件處理程序:

private void toolTipBalloon_Popup(object sender, PopupEventArgs e) 
{ 
    // Set title of tooltip to control's accessible name or text 
    Control ctrl = e.AssociatedControl; 

    if (!String.IsNullOrEmpty(ctrl.AccessibleName)) 
    toolTipBalloon.ToolTipTitle = ctrl.AccessibleName; 
    else if (!String.IsNullOrEmpty(ctrl.Text)) 
    toolTipBalloon.ToolTipTitle = ctrl.Text; 
} 

回答

1

你必須工具提示分配給在某一點的控制。

toolTipBalloon.SetToolTip(ctrl, "Message"); 

您還可以將不同消息的多個控件添加到同一個工具提示中。

toolTipBalloon.SetToolTip(btnStart, "Start the thingy!"); 
toolTipBalloon.SetToolTip(lblSpeed, "You're going thiiiis fast."); 
toolTipBalloon.SetToolTip(txtName, "Enter your super hero name."); 
+0

我已經爲表單中的所有控件添加了此代碼。但是有時候工具提示氣球即將到來。 – Ravindra

+0

@Ravindra你是什麼意思的「來」?我不確定你的實際問題是誠實的,對不起。你可以試着給出更詳細的解釋嗎? –

+0

我在表單構造函數中分配了toolTipBallon.SetToolTip(chkBoxName,「Hello」)。此複選框控件在第一次不會顯示。基於某些條件,複選框控件將可見。這個工具提示氣球不會每次都來。某些時候,控制節目不會顯示工具提示框。我不確定爲什麼這樣發生。 – Ravindra