C#筆記——自定義ToolTip
阿新 • • 發佈:2019-02-05
ToolTip用來表示一個長方形的小彈出視窗,該視窗在使用者將指標懸停在一個控制元件上時顯示有關該控制元件用途的簡短說明。
實現程式碼如下:
private void FormLoad(object sender, EventArgs e)
{
// Create the ToolTip and associate with the Form container.
ToolTip toolTip = new ToolTip();
// Set up the delays for the ToolTip.
toolTip.AutoPopDelay = 500; //工具提示保持可見的時間期限
toolTip.InitialDelay = 100; //滑鼠放上,自動開啟提示的時間
toolTip.ReshowDelay = 50; //滑鼠離開,自動關閉提示的時間
toolTip.ShowAlways = true; //總是顯示,即便空間非活動
toolTip.UseAnimation = true; //動畫效果
toolTip.UseFading = true; //淡入淡出效果
toolTip.IsBalloon = true; //氣球狀外觀
// Set up the ToolTip text for the Button
toolTip.SetToolTip(this.button1, "這是一個按鍵");
}
效果圖: