2011-01-27 77 views
4

是否有一種簡單的方法在C#/ WinForms中創建和顯示自定義工具提示控件?WinForms中的自定義工具提示控制

我現在的想法是要麼:

  • 創建工具提示的子類, 重寫OnPaint方法,將其設置 作爲父控件的工具提示

  • 創建表單的一個子類,並顯示 它手動

有什麼想法?

+0

來吧!有什麼問題? – 2011-01-27 15:54:44

回答

3

這取決於你需要什麼工具提示。如果你只需要一個工具提示氣球造型,動畫和衰落與自定義文本顏色和背景的影響,這是比較容易使用的工具提示控制

// Create your control 
System.Windows.Forms.Button trialButton = new Button(); 
trialButton.Text = "Trial Button"; 

// Tool tip string 
string toolTipText = "Hello World"; 
// ToolTip toolTip = new ToolTip(this.components); 
ToolTip toolTip = new ToolTip(); 
toolTip.ToolTipTitle = "ToolTip Title"; 
toolTip.UseAnimation = true; 
toolTip.UseFading = true; 
toolTip.IsBalloon = true; 
toolTip.Active = true; 
toolTip.SetToolTip(button, toolTipText);