zoukankan      html  css  js  c++  java
  • WinForm ToolTip使用方法

    第一种

    using System.Drawing;
    using System.Windows.Forms;
     
    namespace WinFormUtilHelpV2
    {
      /// <summary>
      /// 基于.NET 2.0的Tooltip工具类
      /// </summary>
      public static class TooltipToolV2
      {
        /// <summary>
        /// 为控件提供Tooltip
        /// </summary>
        /// <param name="control">控件</param>
        /// <param name="tip">ToolTip</param>
        /// <param name="message">提示消息</param>
        public static void ShowTooltip(this Control control, ToolTip tip, string message)
        {
          Point _mousePoint = Control.MousePosition;
          int _x = control.PointToClient(_mousePoint).X;
          int _y = control.PointToClient(_mousePoint).Y;
          tip.Show(message, control, _x, _y);
          tip.Active = true;
        }
        /// <summary>
        /// 为控件提供Tooltip
        /// </summary>
        /// <param name="control">控件</param>
        /// <param name="tip">ToolTip</param>
        /// <param name="message">提示消息</param>
        /// <param name="durationTime">保持提示的持续时间</param>
        public static void ShowTooltip(this Control control, ToolTip tip, string message, int durationTime)
        {
          Point _mousePoint = Control.MousePosition;
          int _x = control.PointToClient(_mousePoint).X;
          int _y = control.PointToClient(_mousePoint).Y;
          tip.Show(message, control, _x, _y, durationTime);
          tip.Active = true;
        }
        /// <summary>
        /// 为控件提供Tooltip
        /// </summary>
        /// <param name="control">控件</param>
        /// <param name="tip">ToolTip</param>
        /// <param name="message">提示消息</param>
        /// <param name="xoffset">水平偏移量</param>
        /// <param name="yoffset">垂直偏移量</param>
        public static void ShowTooltip(this Control control, ToolTip tip, string message, int xoffset, int yoffset)
        {
          Point _mousePoint = Control.MousePosition;
          int _x = control.PointToClient(_mousePoint).X;
          int _y = control.PointToClient(_mousePoint).Y;
          tip.Show(message, control, _x + xoffset, _y + yoffset);
          tip.Active = true;
        }
        /// <summary>
        /// 为控件提供Tooltip
        /// </summary>
        /// <param name="control">控件</param>
        /// <param name="tip">ToolTip</param>
        /// <param name="message">提示消息</param>
        /// <param name="xoffset">水平偏移量</param>
        /// <param name="yoffset">垂直偏移量</param>
        /// <param name="durationTime">保持提示的持续时间</param>
        public static void ShowTooltip(this Control control, ToolTip tip, string message, int xoffset, int yoffset, int durationTime)
        {
          Point _mousePoint = Control.MousePosition;
          int _x = control.PointToClient(_mousePoint).X;
          int _y = control.PointToClient(_mousePoint).Y;
          tip.Show(message, control, _x + xoffset, _y + yoffset, durationTime);
          tip.Active = true;
        }
      }
    }
     
     
    第二种
     
    1. private void SetRadioButtonToolTip()
    2. {
    3.     // Create the ToolTip and associate with the Form container.
    4.     ToolTip toolTip1 = new ToolTip();
    5.     // Set up the delays for the ToolTip.
    6.     toolTip1.AutoPopDelay = 5000;
    7.     toolTip1.InitialDelay = 1000;
    8.     toolTip1.ReshowDelay = 500;
    9.     // Force the ToolTip text to be displayed whether or not the form is active.
    10.     toolTip1.ShowAlways = true;
    11.     // Set up the ToolTip text for the Button and Checkbox.
    12.     toolTip1.SetToolTip(this.radioButton4, "光标");
    13.     toolTip1.SetToolTip(this.radioButton1, "标签");
    14.     toolTip1.SetToolTip(this.radioButton2, "面板");
    15.     toolTip1.SetToolTip(this.radioButton3, "按钮");
    16. }
  • 相关阅读:
    AFNetworking使用总结
    使用Attiny 85开发板制作BadUSB
    C# 按指定数量从前面或者后面删除字符串
    C# 获取打印机列表
    【解决】该任务映像已损坏或已篡改。(异常来自HRESULT:0x80041321)
    PowerShell 解锁使用浏览器下载的文件
    C#使用HttpHelper万能框架,重启路由器
    【解决】应用程序无法正常启动(0xc000007b)。请单击“确定”关闭应用程序。
    Windows 7 IE11 F12 不能正常使用
    HTML5 图片上传预览
  • 原文地址:https://www.cnblogs.com/FLWL/p/7242857.html
Copyright © 2011-2022 走看看